Skip to main content

Pandoc filter to allow file and header includes

Project description

pandoc-include

PyPI PyPI - Downloads GitHub

Pandoc filter to allow file and header 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 (supported from v0.6.0): Use !include-header file.yaml 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.yaml

Or

$include somefolder/somefile

$include-header file.yaml

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.

Examples

File include

File include 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.

Header include

For header include, it is useful to define a header template and include it in many files.

For example, in the header.yaml, we can define basic info:

name: xxx
school: yyy
email: zzz

In the main.md, we can extend the header:

---
title: Title
---

!include-header header.yaml

# Section

Body

The main.md then is equivalent to the follow markdown:

---
title: Title
name: xxx
school: yyy
email: zzz
---

# Section

Body

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.7.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distributions

pandoc_include-0.7.0-py3.7.egg (6.7 kB view details)

Uploaded Source

pandoc_include-0.7.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pandoc-include-0.7.0.tar.gz
Algorithm Hash digest
SHA256 8267a1671999f19e04797359c8231c4ece01c97b5eb3fea7341264d1cc998c51
MD5 4a4ce131058072d5d8394ec82fa74b1f
BLAKE2b-256 8b3dd0c4f4eedf9da64e6f1e6d93374876a5135e37b6c0329b06cff3265101a7

See more details on using hashes here.

File details

Details for the file pandoc_include-0.7.0-py3.7.egg.

File metadata

  • Download URL: pandoc_include-0.7.0-py3.7.egg
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for pandoc_include-0.7.0-py3.7.egg
Algorithm Hash digest
SHA256 822672f59290d82a84e8ee5906b36a1716f08d6f2f1d7bf396ef05a5bc2bf62a
MD5 46dde207499bf71f549bbf4c5bb606bf
BLAKE2b-256 b8b0101cac18ff40b21a6ba805044ec4000aa1e3193f081c81ff816cd1f98566

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pandoc_include-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 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/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for pandoc_include-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05705c3ff3dcd6f192aa27eb2a590a67c0c733dd6e01a3ea4c58c9ca5084a5a6
MD5 f0af0f1adcc925c98d2a751ad6a29795
BLAKE2b-256 d0551d4a9cedf6dbf29a30922f42b4c8f8a127f30e644830ca5b8653dfaaa73a

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