Skip to main content

Pandoc filter to allow file includes

Project description

pandoc-include

PyPI PyPI - Downloads GitHub

Pandoc filter to allow file includes.

The filter script is based on User Guide for Panflute. This repository is to provide a simple way to install and use it.

Features

  • Recursive include (supported from v0.4.0): It depends on include-entry header to work
  • Yaml header Merging (supported from v0.5.0): When an included file has its header, it will be merged into the current header. If there's a conflict, the original header of the current file remains.
  • Header include only (supported from v0.5.1): Use !include-header file.md to include Yaml header from file.

Installation

First, install python and python-pip.

Then, use pip to install:

pip install --user pandoc-include

After installation, make sure that the pandoc-include executable is put in the directory which is in the PATH environment.

Usage

Command

To use this filter, add to pandoc command

pandoc input.md --filter pandoc-include -o output.pdf

Header option

---
include-entry: 'path'
---

This option is to make recursive includes work.

The include-entry option is a path relative to current working directory or absolute where the entry file (the initial file) locates. It should be placed in the entry file only, not in the included files. It is optional and the default include-entry value is ..

For example, to compile a file in current directory, no header is needed:

pandoc test.md --filter pandoc-include -o test.pdf

However, to compile a file not in current directory, like:

pandoc dir/test.md --filter pandoc-include -o test.pdf

The header should now be set to: include-entry: 'dir'.

Syntax

Each include statement has its own line and has the syntax:

!include somefolder/somefile

!include-header file.md

Or

$include somefolder/somefile

$include-header file.md

Each include statement must be in its own paragraph. That is, in its own line and separated by blank lines.

The path can be either absolute or relative to the current file's directory. (If the include statement is in an included file, then the path is relative to the included file itself.) If no extension was given, ".md" is assumed.

For example, it can be used to separate chapters into different files, or include some latex files:

---
title: Article
author: Author
toc: true
---

!include chapters/chap01.md

!include chapters/chap02.md

!include chapters/chap03.md

!include data/table.tex

Recursive include is supported from v0.4.0.

Note: The second syntax may lead to wrong highlighting when using a markdown editor. If it happens, use the first syntax.

License

MIT License

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-include-0.5.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

pandoc_include-0.5.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pandoc-include-0.5.1.tar.gz.

File metadata

  • Download URL: pandoc-include-0.5.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for pandoc-include-0.5.1.tar.gz
Algorithm Hash digest
SHA256 38ef0516e5f74850669c46f12c16de7654d0a77447905017f41b2785cc1f9c9c
MD5 d74d03d63f4a756b01e0c9d93e0105ef
BLAKE2b-256 bdaa54ec1c75826e8f89795b469038f3626aa3dfc604f9c0f7e758e8cc141bab

See more details on using hashes here.

File details

Details for the file pandoc_include-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: pandoc_include-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for pandoc_include-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c835e4bd3ab3124bb824804e77f699b00cfce56f87eb0ff74b6a091d48161d1e
MD5 cf9d43f6d80e7c25076004fff61ebc72
BLAKE2b-256 90cfc6b01e4654d18ac641fc391ab2e2f6b590be41848d0aff91c225eb828e23

See more details on using hashes here.

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