Skip to main content

Yet another pandoc filter to include external code files.

Project description

Pandoc-import-code

PyPI GitHub release (latest SemVer including pre-releases)

Pandoc filter to include external code files as fenced code blocks using the Vuepress syntax.

Install

To install pandoc-import-code, open the command line and type:

pip install pandoc-import-code

Python 3.6+ and PyPy3 are supported.

Usage

:warning: pandoc-import-code requires Pandoc 2.11+, as it relies on Panflute 2

Command

$ pandoc source.md --filter pandoc-import-code -o output.md

Syntax

<<< @/<path>#[region]
  • path : path to a code file to import
    • relative to the pandoc command working directory
  • region : custom region name for partial import

Example

$ pandoc docs/index.md --filter pandoc-import-code -o out.md

Source (./docs/index.md)

# Code Sample

<<< @/samples/hello-world.html#title

Code sample (./samples/hello-world.html)

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Document</title>
  </head>
  <body>
    <!-- #region title -->
    <h1>
      Hello World!
    </h1>
    <!-- #endregion title -->
  </body>
</html>

Output (./out.md)

# Code Sample

``` {.html}
<h1>
  Hello World
</h1>
```

Limitations

  • as line-highlighting isn't supported by pandoc, any {1-2} parameter will be ignored

Dev Install

After cloning the repository and opening the pandoc-import-code folder:

python setup.py install: installs the package locally

python setup.py develop: installs locally with a symlink so changes are automatically updated

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandoc-import-code-1.0.0.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

pandoc_import_code-1.0.0-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page