{"id":21678,"library":"panflute","title":"Panflute","description":"Panflute is a Pythonic library for writing Pandoc filters. It provides an easy-to-use API to traverse and modify the Pandoc AST. Current version is 2.3.1, compatible with Python >=3.7 and Pandoc 3.1.x. Releases follow Pandoc API updates.","status":"active","version":"2.3.1","language":"python","source_language":"en","source_url":"https://github.com/sergiocorreia/panflute","tags":["pandoc","filter","ast","markdown","document-conversion"],"install":[{"cmd":"pip install panflute","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"run_filter is not a top-level function; use pf.run_filter or from panflute.tools import run_filter","wrong":"from panflute import run_filter","symbol":"run_filter","correct":"import panflute as pf"},{"note":"Header is available directly from panflute","wrong":"from panflute.elements import Header","symbol":"Header","correct":"from panflute import Header"}],"quickstart":{"code":"import panflute as pf\n\ndef capitalize_headers(elem, doc):\n    if isinstance(elem, pf.Header):\n        return pf.Header(pf.stringify(elem).upper(), level=elem.level)\n\nif __name__ == '__main__':\n    pf.run_filter(capitalize_headers)","lang":"python","description":"Basic Pandoc filter to uppercase all headers. Run with pandoc: pandoc input.md --filter script.py -o output.md"},"warnings":[{"fix":"Replace references to pf.Null with appropriate handling (e.g., skip or convert to pf.Plain).","message":"Null block element removed in version 2.3.0. Filters relying on Null must be updated.","severity":"breaking","affected_versions":">=2.3.0"},{"fix":"Ensure pandoc version is 3.0+ when using panflute 2.3.0+.","message":"Figure block element added in version 2.3.0. Pandoc 3.0+ required, older pandoc versions incompatible.","severity":"breaking","affected_versions":">=2.3.0"},{"fix":"Use pf.run_pandoc() with a filter function for better control.","message":"The run_filter function is deprecated in favor of run_pandoc or direct usage of the returned document.","severity":"deprecated","affected_versions":"<3.0 (future)"},{"fix":"Update panflute or always provide a caption string.","message":"Table caption handling: In Panflute 2.1.4+, Table() allows no caption. Older versions might crash with None caption.","severity":"gotcha","affected_versions":"<2.1.4"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run pip install panflute","cause":"Panflute not installed.","error":"ModuleNotFoundError: No module named 'panflute'"},{"fix":"Add shebang #!/usr/bin/env python3 and ensure the script is executable.","cause":"Pandoc filter script shebang line missing or wrong Python path.","error":"pandoc: panflute: /usr/bin/env: 'python': No such file or directory"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}