Pandoc Filters

Christophe Demko edited this page Aug 21, 2018 · 80 revisions

Pandoc provides an interface for users to write programs (known as filters) which act on the intermediate AST. A tutorial about filters can be found here.

This page collects together third party filters which can be used to add functionality to pandoc.

Writing Filters

Filters can be written in any programming language. Pandoc wrappers and interfaces are available in the following programming languages to facilitate modification of the AST:

language link description
Python pandocfilters a library for writing pandoc filters in python.
Python panflute a pythonic alternative to pandocfilters, with batteries included.(@jgm recommended this in pandoc discuss)
PHP pandocfilters-php a port of the python pandocfilters module to PHP to make writing filters in PHP easier.
Node.js pandoc-filter-node a Node.js module for writing pandoc filters in JavaScript.
Perl Pandoc::Elements a CPAN module for writing pandoc filters in Perl.
Groovy groovy-pandoc a library for writing Pandoc filters in Groovy.
Ruby paru a Ruby gem to write pandoc filters in Ruby.

Other tools:

  • vimhl, a vim plugin that makes vim syntax highlighting engine available in pandoc.
  • pandoc-jats, a Lua custom writer for Pandoc generating JATS XML.
  • pandocmeta.lua, a simple Lua package that converts Pandoc metadata types into a, possibly multi-dimensional, table.

Written Filters

The following is a list of some known 3rd party filters:

  • Document (DOCX/ODT) related:
  • Images related:
    • pandoc-svg, a pandoc filter to convert svg files to pdf by Jerome Robert.
    • diagrams-pandoc for inserting images expressed in the Haskell diagrams DSL.
    • mermaid-pandoc for inserting images expressed in mermaid syntax
    • r-pandoc for inserting plots expressed in the R language
    • paru-screenshot.rb for automatically taking a screen shot of a web page and including that shot as an image in a markdown file.
  • Numbering related:
    • Numerical reference to sections, using a specified sign (by default #) in internal links. Metadata can configure special sign and whether links should be preserved or converted to plain text.
    • pandoc-fignos, for numbering figures and figure references.
    • pandoc-eqnos, for numbering equations and equation references.
    • pandoc-tablenos, for numbering tables and table references.
    • pandoc-crossref, for numbering and cross-referencing figures, equations and tables
    • pandoc-numbering, for numbering and cross-referencing any kinds of things such as examples, theorems, exercises and so on
    • pandoc-listof, for creating lists of any kinds (deprecated)
    • pandoc-amsthm: a pandoc amsthm package to define the use of amsthm through YAML front matter, target at HTML and LaTeX outputs. For HTML, CSS counter is used and defined in a template (by the YAML variables). For LaTeX amsthm package is used and defined in a template (by the YAML variables).
  • Math related:
    • pandoc-mathjax-filter rendering math to SVG using mathjax-node
    • mathjax-pandoc-filter rendering math to SVG using mathjax-node
    • asciimathml-pandocfilter: to add read support for AsciiMathML syntax through conversion into LaTeX
    • pandoc-unicode-math replaces Unicode math symbols and greek letters like ∀, ∈, →, λ, or Ω in math environments by equivalent Latex commands like \forall, \in, \rightarrow, \lambda, or \Omega.
  • LaTeX related:
  • RAW related:
  • Tables related:
  • Text related:
    • pandoc-abbreviations allows the use of arbitrary abbreviations, defined in an abbreviations file or in the source document's YAML header, which are replaced on processing. Useful for maintaining consistency of terminology etc.
    • pandoc-lang automatically detects the (natural) language of text, as well as the programming language of code blocks
    • pandoc-mustache replaces variables like {{varname}} in a pandoc document with their values, which are stored in a separate YAML file.
    • pandoc-quotes replaces plain, that is, non-typographic, quotation marks with typographic ones for languages other than English.
  • Running Code related:
    • R-pandoc for generating R plots
    • filter_pandoc_run_py for executing python codes written in code blocks and also embedding print output and pyplot figures
  • Others:
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.