예제 #1
0
def test_simple__multiline_paragraph():
    test = \
    """
    This is a test of the assembler. 
    This line should be followed by a  
    br tag
    """

    test = textwrap.dedent(test).strip()

    expected_text =\
    [
        "This is a test of the assembler. ",
        "This line should be followed by a  ",
        E("br"),
        "br tag"
    ]

    root_kwargs = {"class": "brutemark_root"}
    root = E("div", E("p", *expected_text), **root_kwargs)
    expected = tostring(root, pretty_print=True, encoding="unicode")

    actual_string = markdown(test)

    assert expected == actual_string
예제 #2
0
def test_simple_multiple_ordered_list():
    test = "\n".join(["1. First item", "2. Second item"])

    root_kwargs = {"class": "brutemark_root"}
    expected = tostring(E(
        "div", E("ol", E("li", "First item"), E("li", "Second item")),
        **root_kwargs),
                        pretty_print=True,
                        encoding="unicode")
    actual = markdown(test)

    assert actual == expected
예제 #3
0
def test_simple_generation_single_header():
    test = \
    textwrap.dedent("""
    # Hello World
    """).strip()

    expected = tostring(E("div", E("h1", "Hello World"),
                          **{"class": "brutemark_root"}),
                        pretty_print=True,
                        encoding="unicode")
    actual = markdown(test)

    assert actual == expected
예제 #4
0
def test_mixed_lists():

    test = "\n".join(["1. item 1", " * subitem A", "2. item 2"])

    expected = tostring(E(
        "div",
        E("ol", E("li", "item 1", E("ul", E("li", "subitem A"))),
          E("li", "item 2")), **{"class": "brutemark_root"}),
                        pretty_print=True,
                        encoding="unicode")

    actual = markdown(test)

    assert actual == expected
예제 #5
0
def test_inline_HTML():

    test = \
"""<table>
  <tr>
   <td>Foo</td>
  </tr>
</table>"""

    root = E("div", **{"class": "markdown_root"})

    expected = \
"""<div class="brutemark_root"><table>
  <tr>
   <td>Foo</td>
  </tr>
</table></div>"""

    actual = markdown(test, pretty_print=False)
    assert actual == expected
예제 #6
0
def test_simple_multiline_code():

    test = ["    This is a code block", "    that spans", "    multiple lines"]
    test = "\n".join(test)

    expected_text = \
    [
        "This is a code block\n",
        "that spans\n",
        "multiple lines"
    ]

    root_kwargs = {"class": "brutemark_root"}
    expected = tostring(E("div", E("pre", E("code", *expected_text)),
                          **root_kwargs),
                        pretty_print=True,
                        encoding="unicode")

    actual = markdown(test)

    assert actual == expected
예제 #7
0
def test_multidepth_lists():

    test = "\n".join([
        "1. item 1", " * subitem A", " * subitem B", "  12. super nested item"
        "2. item 2"
    ])

    expected = tostring(E(
        "div",
        E(
            "ol",
            E(
                "li", "item 1",
                E("ul", E("li", "subitem A"),
                  E("li", "subitem B", E("ol", E("li",
                                                 "super nested item"))))),
            E("li", "item 2")), **{"class": "brutemark_root"}),
                        pretty_print=False,
                        encoding='unicode').replace("\n", "")

    actual = markdown(test, pretty_print=False)

    assert actual == expected