How to use the pandocfilters.Para function in pandocfilters

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 ospray / ospray / doc / filter-latex.py View on Github external
def tbl_contents(s):
    result = []
    for row in s:
        para = []
        for col in row:
            if col:
                para.extend(col[0]['c'])
            para.append(inlatex(' & '))
        result.extend(para)
        result[-1] = inlatex(r'\\' '\n')
    return pf.Para(result)
github dtrckd / pymake / repo / ml / data / plot / texfilter.py View on Github external
def tbl_headers(s):
    #print(s, s[0], len(s), file=sys.stderr)
    if s[0]:
        start = 1
        result = s[0][0]['c'][:]
    else:
        start = 2
        result = s[1][0]['c'][:]
    for i in range(start, len(s)):
        result.append(inlatex(' & '))
        result.extend(s[i][0]['c'])
    result.append(inlatex(r' \\\midrule'))
    return pf.Para(result)
github kiwi0fruit / knitty / knitty / stitch / stitch.py View on Github external
else:
            # we are saving to filesystem
            ext = mimetypes.guess_extension(key)
            filepath = os.path.join(self.resource_dir,
                                    "{}{}".format(chunk_name, ext))
            os.makedirs(self.resource_dir, exist_ok=True)
            if ext == '.svg':
                with open(filepath, 'wt', encoding='utf-8') as f:
                    f.write(data)
            else:
                with open(filepath, 'wb') as f:
                    f.write(base64.decodebytes(data.encode('utf-8')))
            # Image :: alt text (list of inlines), target
            # Image :: Attr [Inline] Target
            # Target :: (string, string)  of (URL, title)
            block = Para([Image([chunk_name, [], []],
                                [Str(caption)],
                                [filepath, "fig: {}".format(chunk_name)])])

        return block
github tomduck / pandoc-fignos / pandoc_fignos.py View on Github external
def _add_markup(fmt, fig, value):
    """Adds markup to the output."""

    # pylint: disable=global-statement
    global has_tagged_figures  # Flags a tagged figure was found

    if fig['is_unnumbered']:
        if fmt in ['latex', 'beamer']:
            # Use the no-prefix-figure-caption environment
            return [RawBlock('tex', r'\begin{fignos:no-prefix-figure-caption}'),
                    Para(value),
                    RawBlock('tex', r'\end{fignos:no-prefix-figure-caption}')]
        return None  # Nothing to do

    attrs = fig['attrs']
    ret = None

    if fmt in ['latex', 'beamer']:
        if fig['is_tagged']:  # A figure cannot be tagged if it is unnumbered
            # Use the tagged-figure environment
            has_tagged_figures = True
            ret = [RawBlock('tex', r'\begin{fignos:tagged-figure}[%s]' % \
                            str(targets[attrs.id].num)),
                   Para(value),
                   RawBlock('tex', r'\end{fignos:tagged-figure}')]
    elif fmt in ('html', 'html5', 'epub', 'epub2', 'epub3'):
        if LABEL_PATTERN.match(attrs.id):
github aaren / pandoc-reference-filter / internalreferences / internalreferences.py View on Github external
if format in self.formats:
            figure = figure_styles[format].format(attr=attr,
                                                  filename=filename,
                                                  alt=fcaption,
                                                  fcaption=fcaption,
                                                  caption=caption,
                                                  star=star).encode('utf-8')

            return RawBlock(format, figure)

        else:
            alt = [pf.Str(fcaption)]
            target = (filename, '')
            image = pf.Image(alt, target)
            figure = pf.Para([image])
            return pf.Div(attr.to_pandoc(), [figure])