How to use the pandocfilters.RawBlock 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 aaren / pandoc-reference-filter / internalreferences.py View on Github external
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)
github tomduck / pandoc-tablenos / pandoc_tablenos.py View on Github external
if table['is_unnumbered']:
        if fmt in ['latex', 'beamer']:
            # Use the no-prefix-table-caption environment
            return [RawBlock('tex',
                             r'\begin{tablenos:no-prefix-table-caption}'),
                    Table(*(value if len(value) == 5 else value[1:])),
                    RawBlock('tex', r'\end{tablenos:no-prefix-table-caption}')]
        return None  # Nothing to do

    attrs = table['attrs']
    ret = None

    if fmt in ['latex', 'beamer']:
        if table['is_tagged']:  # A table cannot be tagged if it is unnumbered
            has_tagged_tables = True
            ret = [RawBlock('tex', r'\begin{tablenos:tagged-table}[%s]' % \
                            references[attrs.id].num),
                   AttrTable(*value),
                   RawBlock('tex', r'\end{tablenos:tagged-table}')]
    elif fmt in ('html', 'html5', 'epub', 'epub2', 'epub3'):
        if LABEL_PATTERN.match(attrs.id):
            # Enclose table in hidden div
            pre = RawBlock('html', '<div class="tablenos" id="%s">'%attrs.id)
            post = RawBlock('html', '</div>')
            ret = [pre, AttrTable(*value), post]
    elif fmt == 'docx':
        # As per http://officeopenxml.com/WPhyperlink.php
        bookmarkstart = \
          RawBlock('openxml',
                   ''
                   %attrs.id)
        bookmarkend = \
github grea09 / pancake / filter / pandoc-table.py View on Github external
def latex(s):
    return pf.RawBlock('latex', s)
github tomduck / pandoc-tablenos / pandoc_tablenos.py View on Github external
attrs = table['attrs']
    ret = None

    if fmt in ['latex', 'beamer']:
        if table['is_tagged']:  # A table cannot be tagged if it is unnumbered
            has_tagged_tables = True
            ret = [RawBlock('tex', r'\begin{tablenos:tagged-table}[%s]' % \
                            references[attrs.id].num),
                   AttrTable(*value),
                   RawBlock('tex', r'\end{tablenos:tagged-table}')]
    elif fmt in ('html', 'html5', 'epub', 'epub2', 'epub3'):
        if LABEL_PATTERN.match(attrs.id):
            # Enclose table in hidden div
            pre = RawBlock('html', '<div class="tablenos" id="%s">'%attrs.id)
            post = RawBlock('html', '</div>')
            ret = [pre, AttrTable(*value), post]
    elif fmt == 'docx':
        # As per http://officeopenxml.com/WPhyperlink.php
        bookmarkstart = \
          RawBlock('openxml',
                   ''
                   %attrs.id)
        bookmarkend = \
          RawBlock('openxml', '')
        ret = [bookmarkstart, AttrTable(*value), bookmarkend]
    return ret
github pystitch / stitch / stitch / stitch.py View on Github external
if self.to in ('latex', 'pdf', 'beamer'):
                    if 'text/latex' in all_data.keys():
                        key = 'text/latex'
                        data = all_data[key]

                if key == 'text/plain':
                    # ident, classes, kvs
                    blocks = plain_output(data, self.pandoc_extra_args, pandoc)
                elif key == 'text/latex':
                    blocks = [RawBlock('latex', data)]
                elif key == 'text/html':
                    blocks = [RawBlock('html', data)]
                elif key == 'application/javascript':
                    script = ''.format(
                        data)
                    blocks = [RawBlock('html', script)]
                elif key.startswith('image') or key == 'application/pdf':
                    blocks = [self.wrap_image_output(chunk_name, data, key,
                                                     attrs)]
                else:
                    blocks = tokenize_block(data, self.pandoc_extra_args)

            output_blocks += blocks
        return output_blocks