How to use the pandocfilters.Div 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-latex-environment / tests / test_div.py View on Github external
{
                                    'c': 'class2',
                                    't': 'Str'
                                }
                            ],
                            't': 'MetaInlines'
                        }
                    ],
                    't': 'MetaList'
                }
            },
            't': 'MetaMap'
        }
    }

    src = json.loads(json.dumps(Div(
        [
            '',
            [
                'class1',
                'class2'
            ],
            [
                ['title', 'theTitle']
            ]
        ],
        [
            {
                'c': [
                    {
                        'c': 'content',
                        't': 'Str'
github swcarpentry / shell-novice / tools / filters / blockquote2div.py View on Github external
if len(classes) == 1 and classes[0] in SPECIAL_CLASSES:
            panel_kind, glyphicon_kind = SPECIAL_CLASSES[classes[0]]

            h_level, h_attr, h_inlines = blockquote[0]['c']

            # insert an icon as the first sub-item of the header
            span = pf.Span(["", ["glyphicon", glyphicon_kind], []], [])
            h_inlines.insert(0, span)

            # only the header goes into panel-heading
            # WARNING: pandoc doesn't preserve header attributes when the
            #          header is nested under blockquote.  This makes it
            #          impossible to alter header's "class" attribute, for
            #          example.
            header = pf.Header(h_level, h_attr, h_inlines)
            panel_header = pf.Div(("", ["panel-heading"], []), [header])

            # the rest of the blockquote goes into panel-body
            panel_body = pf.Div(("", ["panel-body"], []), blockquote[1:])

            # apply Bootstrap panel classes to the div
            classes.append("panel")
            classes.append(panel_kind)

            # a blockquote is just a list of blocks, so it can be
            # passed directly to Div, which expects Div(attr, blocks)
            return pf.Div((id, classes, kvs), [panel_header, panel_body])
github tomduck / pandoc-fignos / pandoc_fignos.py View on Github external
# Chop up the doc
    meta = doc['meta'] if PANDOCVERSION >= '1.18' else doc[0]['unMeta']
    blocks = doc['blocks'] if PANDOCVERSION >= '1.18' else doc[1:]

    # Process the metadata variables
    process(meta)

    # First pass
    replace = PANDOCVERSION >= '1.16'
    attach_attrs_image = attach_attrs_factory(Image,
                                              extract_attrs=_extract_attrs,
                                              replace=replace)
    detach_attrs_image = detach_attrs_factory(Image)
    insert_secnos_img = insert_secnos_factory(Image)
    delete_secnos_img = delete_secnos_factory(Image)
    insert_secnos_div = insert_secnos_factory(Div)
    delete_secnos_div = delete_secnos_factory(Div)
    altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
                               [attach_attrs_image,
                                insert_secnos_img, insert_secnos_div,
                                process_figures,
                                delete_secnos_img, delete_secnos_div,
                                detach_attrs_image], blocks)

    # Second pass
    process_refs = process_refs_factory(LABEL_PATTERN, targets.keys())
    replace_refs = replace_refs_factory(targets, cleveref, False,
                                        plusname if not capitalise \
                                        or plusname_changed else
                                        [name.title() for name in plusname],
                                        starname)
    attach_attrs_span = attach_attrs_factory(Span, replace=True)
github swig / swig / Doc / Manual / pandoc_filter.py View on Github external
def codeblocks(key, value, format, meta):
  if key == 'CodeBlock':
    [[id, classes, kvs], contents] = value

    newcontents = [html('<pre>\n' + contents + '</pre>')]

    if len(classes) == 0:
      if contents.startswith("$"):
        classes.append("shell")
      else:
        classes.append("code")

    return Div([id, classes, kvs], newcontents)
  if key == 'Header':
    if value[0] == 1:
      the_title = stringify(value)
    value[1][0] = ""
github swcarpentry / shell-novice / tools / filters / blockquote2div.py View on Github external
h_level, h_attr, h_inlines = blockquote[0]['c']

            # insert an icon as the first sub-item of the header
            span = pf.Span(["", ["glyphicon", glyphicon_kind], []], [])
            h_inlines.insert(0, span)

            # only the header goes into panel-heading
            # WARNING: pandoc doesn't preserve header attributes when the
            #          header is nested under blockquote.  This makes it
            #          impossible to alter header's "class" attribute, for
            #          example.
            header = pf.Header(h_level, h_attr, h_inlines)
            panel_header = pf.Div(("", ["panel-heading"], []), [header])

            # the rest of the blockquote goes into panel-body
            panel_body = pf.Div(("", ["panel-body"], []), blockquote[1:])

            # apply Bootstrap panel classes to the div
            classes.append("panel")
            classes.append(panel_kind)

            # a blockquote is just a list of blocks, so it can be
            # passed directly to Div, which expects Div(attr, blocks)
            return pf.Div((id, classes, kvs), [panel_header, panel_body])
github aaren / pandoc-reference-filter / internalreferences.py View on Github external
if format in self.formats:
            figure = self.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])
github swcarpentry / sql-novice-survey / tools / filters / blockquote2div.py View on Github external
if len(classes) == 1 and classes[0] in SPECIAL_CLASSES:
            panel_kind, glyphicon_kind = SPECIAL_CLASSES[classes[0]]

            h_level, h_attr, h_inlines = blockquote[0]['c']

            # insert an icon as the first sub-item of the header
            span = pf.Span(["", ["glyphicon", glyphicon_kind], []], [])
            h_inlines.insert(0, span)

            # only the header goes into panel-heading
            # WARNING: pandoc doesn't preserve header attributes when the
            #          header is nested under blockquote.  This makes it
            #          impossible to alter header's "class" attribute, for
            #          example.
            header = pf.Header(h_level, h_attr, h_inlines)
            panel_header = pf.Div(("", ["panel-heading"], []), [header])

            # the rest of the blockquote goes into panel-body
            panel_body = pf.Div(("", ["panel-body"], []), blockquote[1:])

            # apply Bootstrap panel classes to the div
            classes.append("panel")
            classes.append(panel_kind)

            # a blockquote is just a list of blocks, so it can be
            # passed directly to Div, which expects Div(attr, blocks)
            return pf.Div((id, classes, kvs), [panel_header, panel_body])