ipypublish.filters_pandoc.main module

pandoc filters used in converting markdown to a target format

Other sources of information:

ipypublish.filters_pandoc.main.jinja_filter(source, to_format, nb_metadata, cell_metadata, from_format='markdown', strip=True)[source]

run a set of ipypublish pandoc filters as a Jinja2 filter

We convert the source to an intermediary pandoc-json AST format, run the pandocfilters, then convert to the to_format

Parameters
  • source (str) – content to convert

  • to_format (str) – format of output

  • nb_metadata (dict) – mapping of notebook level metadata

  • cell_metadata (dict) – mapping of cell level metadata

  • from_format (str) – format of source

  • strip (bool) – strip any blank lines from the start/end of the final string

Notes

Available Meta Options

The following options are available in {“ipub”: {}}

apply_filters=True: bool

apply filters to markdown

convert_raw=True: bool

if True attempt to extract non-markdown formats and convert them to the target format, e.g. rst roles to latex tags

at_notation=True: bool

interpret @label as a reference type based on its prefix modifier, latex: ‘’ = cite ‘+’ = cref, ‘^’ = Cref, ‘!’ = ref, ‘=’ = eqref rst: ‘’ = :cite: ‘+’ = :numref: ‘^’ = :numref: ‘!’ = :ref: ‘=’ = :eq:

reftag=”cite”: str

default latex tag for references

use_numref=True: bool

whether to use the :numref: role or just :ref: :numref: requires numfig = True in conf.py and, for section numbering, a toc tree with :numbered:

strip_meta=True: bool

if True strip any source metadata, contained in the top matter

The options will be taken in order of preference from: source.metadata > cell.metadata > nb.metadata

For source.metadata, see https://pandoc.org/MANUAL.html#metadata-blocks:

---
ipub:
  pandoc:
    use_numref: True
---
+@label
ipypublish.filters_pandoc.main.pandoc_filters()[source]

run a set of ipypublish pandoc filters directly on the pandoc AST, via pandoc --filter ipubpandoc