ipypublish.filters_pandoc.prepare_raw module

a panflute filter to find raw elements and convert them to format agnostic Span elements

ipypublish.filters_pandoc.prepare_raw.assess_latex(text, is_block)[source]

test if text is a latex command \tag{content} or \tag[options]{content}

if so return a panflute.Span, with attributes:

  • format: “latex”

  • tag: <tag>

  • options: <options>

  • content: <content>

  • original: <full text>

ipypublish.filters_pandoc.prepare_raw.create_cite_span(identifiers, rawformat, is_block, prefix='', alt=None)[source]

create a cite element from an identifier

ipypublish.filters_pandoc.prepare_raw.finalize(doc)[source]
ipypublish.filters_pandoc.prepare_raw.gather_processors(element, doc)[source]

we gather the processors, so that we don’t have to do multiple passes

ipypublish.filters_pandoc.prepare_raw.main(doc=None, extract_formats=True)[source]

if extract_formats then convert citations defined in latex, rst or html formats to special Span elements

ipypublish.filters_pandoc.prepare_raw.prepare(doc)[source]
ipypublish.filters_pandoc.prepare_raw.process_html_cites(container, doc)[source]

extract raw html <cite data-cite=”cite_key”>text</cite>

extract links that point to internal items, e.g. [text](#label)

ipypublish.filters_pandoc.prepare_raw.process_latex_raw(element, doc)[source]

extract all latex adhering to tag{content} or tag[options]{content} to a Span element with class RAWSPAN_CLASS attributes:

attributes={"format": "latex",
            "tag": tag, "content": content, "options": options}
  • Cref, cref, ref, and cite will aslo have class CONVERTED_CITE_CLASS

  • everything else will also have class CONVERTED_OTHER_CLASS

ipypublish.filters_pandoc.prepare_raw.process_latex_str(block, doc)[source]

see process_latex_raw

same but sometimes pandoc doesn’t convert to a raw element

ipypublish.filters_pandoc.prepare_raw.process_rst_roles(block, doc)[source]

extract rst adhering to :role:`label`, where role is a known to a Cite element with class RAWSPAN_CLASS and CONVERTED_CITE_CLASS and attributes:

attributes={"format": "rst",
            "role": tag, "content": content}
ipypublish.filters_pandoc.prepare_raw.wrap_rst_directives(doc)[source]

search for rst directives and wrap them in divs

with top line starting Str(..)Space()Str(name::), above a CodeBlock, and rst labels of the form Str(..)Space()Str(_name:)