Skip to main content

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

Metadata

Release files for pandoc-include 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pandoc-include 0.6.0
File Size Uploaded Provenance
pandoc-include-0.6.0.tar.gz 4.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pandoc-include 0.6.0
File Interpreter ABI Platform
pandoc_include-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / pandoc-include-0.6.0.tar.gz

Download URL pandoc-include-0.6.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1ffe9576b83cb09756ebce16c3119b54e549ca54d9036b1043601e26080db9e1
BLAKE2b-256 checksum
How to use checksums
f31dc233e52df466bf9d55052fba4b0fe9ac833eed36e2064a83a912267d4652
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pandoc_include-0.6.0-py3-none-any.whl

Download URL pandoc_include-0.6.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69978c15e11905ecda3f09a36b30a215f3ffb2d816bb3f1590a597a917fe3a0f
BLAKE2b-256 checksum
How to use checksums
72a8dd7ca052c9b06f3e56f9e874f9b85403dca3535860ce060ffbdbb0ab5fa4
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for pandoc-include 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page