Exemple #1
0
def test_block_styles():
    assert "```" in BASIC_BLOCK_TXT

    html_data = ext.md_block2html(BASIC_BLOCK_TXT)
    assert '<span class="katex' in html_data
    html_data = ext.md_block2html(BASIC_BLOCK_TXT.replace("```", "````"))
    assert '<span class="katex' in html_data
    html_data = ext.md_block2html(BASIC_BLOCK_TXT.replace("```", "~~~~"))
    assert '<span class="katex' in html_data
    html_data = ext.md_block2html(BASIC_BLOCK_TXT.replace("```", "~~~"))
    assert '<span class="katex' in html_data
def test_trailing_whitespace():
    default_output = ext.md_block2html(BASIC_BLOCK_TXT)

    trailing_space_result = md.markdown(BASIC_BLOCK_TXT + "  ", extensions=['markdown_katex'])
    assert "tmp_md_katex" not in trailing_space_result
    assert default_output in trailing_space_result
    assert "```" not in trailing_space_result
def test_tex2html():
    assert len(markdown_katex.TEST_FORMULAS) > 1
    for formula in markdown_katex.TEST_FORMULAS:
        md_text   = "```math\n{0}\n```".format(formula)
        html_text = ext.md_block2html(md_text)
        assert html_text.startswith('<span class="katex-display"')
        assert html_text.endswith("</span>")

        md_text   = "$`{0}`$".format(formula)
        html_text = ext.md_inline2html(md_text)
        assert html_text.startswith('<span class="katex"')
        assert html_text.endswith("</span>")
def test_basic_block():
    html_data = markdown_katex.tex2html(BASIC_TEX_TXT)

    # with open("debug_output_katex.html", mode="w") as fobj:
    #     fobj.write(html_data)

    assert '<span class="katex' in html_data

    no_inline_svg  = ext.md_block2html(BASIC_BLOCK_TXT, default_options={'no_inline_svg': False})
    default_output = ext.md_block2html(BASIC_BLOCK_TXT)
    assert no_inline_svg == default_output
    assert default_output
    assert default_output.startswith('<span class="katex-display"')
    expected = "<p>{}</p>".format(default_output)

    result = md.markdown(BASIC_BLOCK_TXT, extensions=['markdown_katex'])
    assert "tmp_md_katex" not in result

    assert default_output in result

    assert result.strip().startswith(ext.KATEX_STYLES.strip())
    assert result.endswith(expected)