Beispiel #1
0
def RawBlock(format, string):
    """Overwrite pandocfilters RawBlock so that html5
    and html raw output both use the html writer.
    """
    if format == 'html5':
        format = 'html'
    return pf.RawBlock(format, string)
Beispiel #2
0
def enclose_input_code(key, value, format, metadata):
    """Enclose any input code in a div to allow collapsing.

    'Input code' is a code block that has 'n' defined (the prompt
    number).
    """
    if key == 'CodeBlock':
        div_attr = {'classes': ['collapsible']}
        code_attr = PandocAttributes(value[0], format='pandoc')
        if 'n' not in code_attr.kvs:
            return
        else:
            button = pf.RawBlock('html', collapse_button(n=code_attr['n']))
            code = pf.CodeBlock(*value)
            content = [button, pf.Div(pf.attributes({}), [code])]
            return pf.Div(pf.attributes(div_attr), content)
Beispiel #3
0
def latex(s):
    return pf.RawBlock('latex', s)
Beispiel #4
0
def latex_block(s):
   return pandocfilters.RawBlock('latex', s)
Beispiel #5
0
def latex(s):
    return pf.RawBlock("latex", s)
Beispiel #6
0
def html(x):
    """html(x)
The string x is transformed into an RawBlock for Pandoc's usage."""
    assert isinstance(x, str)
    return pandocfilters.RawBlock('html', x)
Beispiel #7
0
import re
import subprocess
import sys
from xml.dom import minidom
from xml.parsers.expat import ExpatError

import pandocfilters

import gleetex
import gleetex.pandoc

from .. import config
from ..errors import MathError, SubprocessError


html = lambda text: pandocfilters.RawBlock("html", text)

# pylint: disable=inconsistent-return-statements
def page_number_extractor(key, value, fmt, meta):
    """Scan all paragraphs for those starting with || to parse it for page
    numbering information."""
    if not (fmt == "html" or fmt == "html5" or fmt == "epub"):
        return
    if key == "Para" and value:
        # find first obj with content (line breaks don't have this)
        text = None
        for obj in value:
            if "c" in obj:
                text = obj["c"]
                break
        if text is None:
Beispiel #8
0
def html(s):
    return pf.RawBlock('html', s)
Beispiel #9
0
def latex(s):
    debug(s)
    return pf.RawBlock('latex', s)