panflute
Pythonic Pandoc filters
What it is and what it does
Panflute is a Python wrapper around Pandoc's document processing pipeline that lets you write filters by manipulating document elements as Python objects rather than working directly with JSON. It depends on click for CLI handling and pyyaml for configuration, and requires a matching Pandoc binary installed on your system to function.
You write a filter function that receives document elements (paragraphs, text, code blocks, etc.) and returns transformed versions of them. Panflute handles the marshalling between Pandoc's JSON representation and Python objects, so you work with readable class instances instead of raw data structures. This is most useful when you need to customize how Pandoc converts between formats—for example, rewriting links, injecting metadata, or applying domain-specific transformations to code blocks.
Use it for:
- Rewrite internal document links or citations during Markdown-to-HTML conversion for a static site generator.
- Transform code blocks with custom syntax into formatted output (e.g., mermaid diagrams to SVG).
- Inject metadata or styling directives into LaTeX output for academic papers written in Markdown.
- Strip or modify elements (images, scripts, comments) when converting documents for different audiences.
- Automate document preprocessing for research workflows that combine Markdown, Pandoc, and custom logic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Panflute provides a Pythonic interface for writing Pandoc filters, allowing you to programmatically transform documents between markup formats by manipulating their abstract syntax trees.
Yes, if you need to programmatically transform documents via Pandoc and want to avoid writing raw JSON filters. Install friction is low and the license is permissive. Be aware that the package has not been released in 877 days; check that your Pandoc version (2.11.0.4–3.1.x for version 2.3.1) is compatible before committing to it for production workflows.
Install
panflute on PyPI
pip
pip install panfluteuv
uv add panflutepoetry
poetry add panfluteInstalling panflute
Before you install
Low friction installation with only two runtime dependencies (click and pyyaml). The package is in production/stable status but has not been released for 877 days; the repository remains active with recent commits, though maintenance appears infrequent.
License in practice
BSD3 license is permissive and poses no restrictions on commercial or private use, modification, or redistribution as long as the license text is included.
Quickstart
pip install panflute
import panflute as pf
def action(elem, doc):
if isinstance(elem, pf.Str):
return pf.Str(elem.text.upper())
if __name__ == '__main__':
pf.run_filter(action)
Requires a compatible Pandoc installation on the system; panflute 2.3.1 supports Pandoc 2.11.0.4–3.1.x and Pandoc API versions 1.22–1.23.
Verify before relying
- Whether the 877-day gap since last release indicates active maintenance or dormancy relative to Pandoc's release cycle.
- Performance characteristics when processing large documents or complex filter chains.
- Compatibility with PyPy in practice, given the classifier indicates support but no runtime evidence is provided.
Package facts
| License | BSD3 (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — click, pyyaml |
| Maintenance | aging — 877 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 169,668/month — #10,411 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: panflute-2.3.1-py3-none-any.whl
Keywords: pandoc, pandocfilters, markdown, latex
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
pandocfiltersProvides Python utilities for writing pandoc…
permissive · top 1,000 on PyPI
pandocPandoc Python Library wraps the Pandoc document…
permissive · top 15,000 on PyPI
pypandocPypandoc wraps pandoc, a universal document…
permissive · top 5,000 on PyPI
pyandocPyandoc wraps Pandoc to convert between…
permissive · top 5,000 on PyPI
pypandoc-binarypypandoc_binary wraps pandoc, a universal…
permissive · top 5,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
setuptools-markdownConverts Markdown files to reStructuredText…
permissive · top 15,000 on PyPI
markdown2Converts Markdown text to HTML using a fast,…
permissive · top 5,000 on PyPI
mistletoemistletoe is a pure-Python Markdown parser that…
permissive · top 5,000 on PyPI
m2r2Converts markdown files with embedded…
permissive · top 15,000 on PyPI