How to use pandocfilters - 10 common examples

To help you get started, we’ve selected a few pandocfilters examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering_prefix_single():
    init()

    src = Para(createListStr(u'Exercise #ex:'))
    dest = Para([
        Span(
            [u'ex:1', ['pandoc-numbering-text', 'ex'], []],
            [Strong(createListStr(u'Exercise 1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], '', {}) == dest

    src = Para(createListStr(u'Exercise #'))
    dest = Para([
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [Strong(createListStr(u'Exercise 1'))]
        )
    ])
github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering_sectioning_map_error():
    init()

    meta = getMeta3()

    sectioning(meta)

    src = Para(createListStr(u'Exercise #'))
    dest = Para([
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [Strong(createListStr(u'Exercise 1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], '', meta) == dest
github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering_sectioning_map():
    init()

    meta = getMeta2()

    sectioning(meta)

    src = Para([Str(u'Exercise'), Space(), Str(u'#')])
    dest = Para([
        Span(
            [u'exercise:2.2.1', ['pandoc-numbering-text', 'exercise'], []],
            [Strong(createListStr(u'Exercise 2.1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], '', meta) == dest
github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering_prefix_single():
    init()

    src = Para(createListStr(u'Exercise #ex:'))
    dest = Para([
        Span(
            [u'ex:1', ['pandoc-numbering-text', 'ex'], []],
            [Strong(createListStr(u'Exercise 1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], '', {}) == dest

    src = Para(createListStr(u'Exercise #'))
    dest = Para([
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [Strong(createListStr(u'Exercise 1'))]
        )
    ])
github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering_latex():
    init()

    src = Para(createListStr(u'Exercise #'))
    dest = Para([
        RawInline(u'tex', u'\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1}{\\ignorespaces Exercise}}'),
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [RawInline('tex', '\\label{exercise:1}'), Strong(createListStr(u'Exercise 1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], 'latex', {}) == dest

    init()

    src = Para(createListStr(u'Exercise (The title) #'))
    dest = Para([
        RawInline(u'tex', u'\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1}{\\ignorespaces The title}}'),
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [
                RawInline('tex', '\\label{exercise:1}'),
                Strong(createListStr(u'Exercise 1')),
                Space(),
github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering_latex():
    init()

    src = Para(createListStr(u'Exercise #'))
    dest = Para([
        RawInline(u'tex', u'\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1}{\\ignorespaces Exercise}}'),
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [RawInline('tex', '\\label{exercise:1}'), Strong(createListStr(u'Exercise 1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], 'latex', {}) == dest

    init()

    src = Para(createListStr(u'Exercise (The title) #'))
    dest = Para([
        RawInline(u'tex', u'\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1}{\\ignorespaces The title}}'),
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [
github chdemko / pandoc-numbering / tests / test_listings.py View on Github external
def listing_latex(meta, color, tab, space):
    init()

    src = Para(createListStr(u'Exercise #'))
    pandoc_numbering.numbering(src['t'], src['c'], 'latex', meta)
    src = Para(createListStr(u'Exercise (test) #'))
    pandoc_numbering.numbering(src['t'], src['c'], 'latex', meta)

    doc = [[{'unMeta': meta}], []]
    pandoc_numbering.addListings(doc, 'latex', meta)

    dest = [
        Header(1, ['', ['unnumbered'], []], createListStr(u'Listings of exercises')),
        RawBlock(
            'tex',
            ''.join([
                '\\hypersetup{linkcolor=' + color + '}',
                '\\makeatletter',
                '\\newcommand*\\l@exercise{\\@dottedtocline{1}{' + tab + 'em}{' + space + 'em}}',
                '\\@starttoc{exercise}',
                '\\makeatother'
            ])
        )
    ]

    assert json.loads(json.dumps(doc[1])) == json.loads(json.dumps(dest))
github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering_title():
    init()

    src = Para(createListStr(u'Exercise (The title) #'))
    dest = Para([
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [
                Strong(createListStr(u'Exercise 1')),
                Space(),
                Emph(createListStr(u'(') + createListStr(u'The title') + createListStr(u')'))
            ]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], '', {}) == dest
github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering_prefix_single():
    init()

    src = Para(createListStr(u'Exercise #ex:'))
    dest = Para([
        Span(
            [u'ex:1', ['pandoc-numbering-text', 'ex'], []],
            [Strong(createListStr(u'Exercise 1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], '', {}) == dest

    src = Para(createListStr(u'Exercise #'))
    dest = Para([
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [Strong(createListStr(u'Exercise 1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], '', {}) == dest
github chdemko / pandoc-numbering / tests / test_numbering.py View on Github external
def test_numbering():
    init()

    src = Para(createListStr(u'Exercise #'))
    dest = Para([
        Span(
            [u'exercise:1', ['pandoc-numbering-text', 'exercise'], []],
            [Strong(createListStr(u'Exercise 1'))]
        )
    ])

    assert pandoc_numbering.numbering(src['t'], src['c'], '', {}) == dest