How to use the panflute.RawBlock function in panflute

To help you get started, we’ve selected a few panflute 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 / pandoc_numbering.py View on Github external
latex_category = re.sub("[^a-z]+", "", category)
    latex = [
        link_color(doc),
        "\\makeatletter",
        "\\newcommand*\\l@"
        + latex_category
        + "{\\@dottedtocline{1}{"
        + str(definition["entry-tab"])
        + "em}{"
        + str(definition["entry-space"])
        + "em}}",
        "\\@starttoc{" + latex_category + "}",
        "\\makeatother",
    ]
    # Return a RawBlock
    return RawBlock("".join(latex), "tex")
github chdemko / pandoc-latex-color / pandoc_latex_color.py View on Github external
def add_latex(elem, color, bgcolor):
    # Is it a Span?
    if isinstance(elem, Span):
        if bgcolor:
            elem.content.insert(0, RawInline(bgcolor + "\\hl{", "tex"))
            elem.content.append(RawInline("}", "tex"))

        elem.content.insert(0, RawInline(color, "tex"))

    # Is it a Div?
    elif isinstance(elem, Div):
        if bgcolor:
            elem.content.insert(0, RawBlock("{" + color + bgcolor + "\\hl{", "tex"))
            elem.content.append(RawBlock("}", "tex"))
        else:
            elem.content.insert(0, RawBlock("{" + color, "tex"))
            elem.content.append(RawBlock("}", "tex"))
github sergiocorreia / panflute / examples / panflute / gabc.py View on Github external
def htmlblock(code):
    """Html block"""
    return RawBlock(code, format='html')
github ickc / pantable / pantable / pantable.py View on Github external
# parse alignment
    alignment = parse_alignment(options.get('alignment', None), n_col)
    del n_col
    # get caption
    caption = options.get('caption', None)

    text = csv_to_grid_tables(
        table_list, caption, alignment,
        (len(table_list) > 1 and options.get('header', True))
    ) if use_grid_tables else csv_to_pipe_tables(
        table_list, caption, alignment
    )

    raw_markdown = options.get('raw_markdown', False)
    if raw_markdown:
        return panflute.RawBlock(text, format='markdown')
    else:
        return panflute.convert_text(text)
github sergiocorreia / panflute / examples / panflute / lilypond.py View on Github external
def latexblock(code):
    """LaTeX block"""
    return RawBlock(code, format='latex')
github chdemko / pandoc-latex-tip / pandoc_latex_tip.py View on Github external
# It is a Div: try to insert an inline raw before the first inline element
        inserted = [False]

        def insert(element, _):
            if (
                not inserted[0]
                and isinstance(element, Inline)
                and not isinstance(element.parent, Inline)
            ):
                inserted[0] = True
                return [RawInline(latex, "tex"), element]
            return None

        elem.walk(insert)
        if not inserted[0]:
            return [RawBlock("\\needspace{5em}", "tex"), RawBlock(latex, "tex"), elem]
        return [RawBlock("\\needspace{5em}", "tex"), elem]

    return None
github chdemko / pandoc-latex-tip / pandoc_latex_tip.py View on Github external
def _add_latex(elem, latex):
    if bool(latex):
        # Is it a Span or a Code?
        if isinstance(elem, (Span, Code)):
            return [elem, RawInline(latex, "tex")]

        # It is a CodeBlock: create a minipage to ensure the _tip to be on the same page as the codeblock
        if isinstance(elem, CodeBlock):
            return [
                RawBlock("\\begin{minipage}{\\textwidth}" + latex, "tex"),
                elem,
                RawBlock("\\end{minipage}", "tex"),
            ]

        # It is a Div: try to insert an inline raw before the first inline element
        inserted = [False]

        def insert(element, _):
            if (
                not inserted[0]
                and isinstance(element, Inline)
                and not isinstance(element.parent, Inline)
            ):
                inserted[0] = True
                return [RawInline(latex, "tex"), element]
            return None
github sergiocorreia / panflute-filters / filters / collapse_code.py View on Github external
def collapse(elem, doc):
    if isinstance(elem, pf.CodeBlock) and "html" in doc.format:
        content = [
            pf.RawBlock("<details>", format="html"),
            pf.RawBlock(
                """
                <summary> Show code </summary>
                """
            ),
            elem,
            pf.RawBlock("</details>", format="html"),
        ]
        div = pf.Div(*content, classes=["collapsible_code"])
        return div