Example #1
0
def test_emphasis():
    data = "Hello *World*"
    expected = [
        'body',
        ['paragraph',
         ['plain', "Hello "],
         ['emphasis', "World"]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = """
<p>Hello <strong>World</strong></p>
    """.strip()
    result = markdown3.to_html(data)
    assert expected == result

    data = "Text with *some bold* in it"
    expected = [
        'body',
        ['paragraph',
         ['plain', "Text with "],
         ['emphasis', "some bold"],
         ['plain', ' in it']]]
    result = markdown3.parse(data)
    assert expected == result

    expected = """
<p>Text with <strong>some bold</strong> in it</p>
    """.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #2
0
def test_emphasis():
    data = "Hello *World*"
    expected = [
        'body', ['paragraph', ['plain', "Hello "], ['emphasis', "World"]]
    ]
    result = markdown3.parse(data)
    assert expected == result

    expected = """
<p>Hello <strong>World</strong></p>
    """.strip()
    result = markdown3.to_html(data)
    assert expected == result

    data = "Text with *some bold* in it"
    expected = [
        'body',
        [
            'paragraph', ['plain', "Text with "], ['emphasis', "some bold"],
            ['plain', ' in it']
        ]
    ]
    result = markdown3.parse(data)
    assert expected == result

    expected = """
<p>Text with <strong>some bold</strong> in it</p>
    """.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #3
0
def test_code_block():
    data = """
    <p>This is some html</p>"""

    expected = [
        'body',
        ['code_block',
         ['code_line',
          "&lt;p&gt;This is some html&lt;/p&gt;"]]]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<code>
  &lt;p&gt;This is some html&lt;/p&gt;
</code>
    """.strip()

    result = markdown3.to_html(data)
    assert expected == result

    # Test list followed by code

    data = """

    1. A bullet point


    <p>This is some html</p>
"""

    expected = [
        'body',
        ['ordered_list',
         ['numbered_bullet_without_paragraph',
          ['plain', "A bullet point"]]],
        ['code_block',
         ['code_line',
          "&lt;p&gt;This is some html&lt;/p&gt;"]]]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<ol>
  <li>A bullet point</li>
</ol>

<code>
  &lt;p&gt;This is some html&lt;/p&gt;
</code>
    """.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #4
0
def test_code_block():
    data = """
    <p>This is some html</p>"""

    expected = [
        'body',
        ['code_block', ['code_line', "&lt;p&gt;This is some html&lt;/p&gt;"]]
    ]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<code>
  &lt;p&gt;This is some html&lt;/p&gt;
</code>
    """.strip()

    result = markdown3.to_html(data)
    assert expected == result

    # Test list followed by code

    data = """

    1. A bullet point


    <p>This is some html</p>
"""

    expected = [
        'body',
        [
            'ordered_list',
            ['numbered_bullet_without_paragraph', ['plain', "A bullet point"]]
        ],
        ['code_block', ['code_line', "&lt;p&gt;This is some html&lt;/p&gt;"]]
    ]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<ol>
  <li>A bullet point</li>
</ol>

<code>
  &lt;p&gt;This is some html&lt;/p&gt;
</code>
    """.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #5
0
def test_title_level_2():
    data = """
## A level two title ##
"""
    expected = [
        'body',
        ['title_level_2', "A level two title "]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<h2>A level two title </h2>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result

    # Without linebreaks

    data = """
## A level two title
""".strip()
    expected = [
        'body',
        ['title_level_2', "A level two title"]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<h2>A level two title</h2>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result

    # With extra linebreaks

    data = """

## A level two title
"""
    expected = [
        'body',
        ['title_level_2', "A level two title"]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<h2>A level two title</h2>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #6
0
    def test_multiple_paragraphs(self):
        data = """
1. Bullet One, Paragraph One
   Paragraph Two

2. Bullet Two
""".strip()

        expected = [
            'body',
            ['ordered_list',
             ['numbered_bullet_with_paragraph',
              ['paragraph',
               ['plain',
                "Bullet One, Paragraph One"]],
              ['paragraph',
               ['plain',
               "Paragraph Two"]]],
             ['numbered_bullet_with_paragraph',
              ['paragraph',
               ['plain',
               "Bullet Two"]]]]]

        result = markdown3.parse(data)
        assert expected == result

        expected = """
<ol>
  <li><p>Bullet One, Paragraph One</p><p>Paragraph Two</p></li>
  <li><p>Bullet Two</p></li>
</ol>
        """.strip()
        result = markdown3.to_html(data)
        assert expected == result
Example #7
0
    def test_with_tabs(self):
        "Test that tabs between the bullet and text work"
        data = """
1.	A numbered bullet
2.	Another numbered bullet"""

        expected = [
            'body',
            ['ordered_list',
             ['numbered_bullet_without_paragraph',
              ['plain', "A numbered bullet"]],
             ['numbered_bullet_without_paragraph',
              ['plain', "Another numbered bullet"]]]]

        result = markdown3.parse(data)
        assert expected == result

        expected = '''
<ol>
  <li>A numbered bullet</li>
  <li>Another numbered bullet</li>
</ol>
        '''.strip()
        result = markdown3.to_html(data).strip()
        assert expected == result
Example #8
0
    def test_multiple_paragraphs(self):
        data = """
1. Bullet One, Paragraph One
   Paragraph Two

2. Bullet Two
""".strip()

        expected = [
            'body',
            [
                'ordered_list',
                [
                    'numbered_bullet_with_paragraph',
                    ['paragraph', ['plain', "Bullet One, Paragraph One"]],
                    ['paragraph', ['plain', "Paragraph Two"]]
                ],
                [
                    'numbered_bullet_with_paragraph',
                    ['paragraph', ['plain', "Bullet Two"]]
                ]
            ]
        ]

        result = markdown3.parse(data)
        assert expected == result

        expected = """
<ol>
  <li><p>Bullet One, Paragraph One</p><p>Paragraph Two</p></li>
  <li><p>Bullet Two</p></li>
</ol>
        """.strip()
        result = markdown3.to_html(data)
        assert expected == result
Example #9
0
    def test_indented(self):
        "Test that an indented bullet works"
        data = """
    1. An indented numbered bullet"""

        expected = [
            'body',
            [
                'ordered_list',
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "An indented numbered bullet"]
                ]
            ]
        ]

        result = markdown3.parse(data)
        assert expected == result

        expected = '''
<ol>
  <li>An indented numbered bullet</li>
</ol>
        '''.strip()
        result = markdown3.to_html(data)
        assert expected == result
Example #10
0
    def test_with_tabs(self):
        "Test that tabs between the bullet and text work"
        data = """
1.	A numbered bullet
2.	Another numbered bullet"""

        expected = [
            'body',
            [
                'ordered_list',
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "A numbered bullet"]
                ],
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "Another numbered bullet"]
                ]
            ]
        ]

        result = markdown3.parse(data)
        assert expected == result

        expected = '''
<ol>
  <li>A numbered bullet</li>
  <li>Another numbered bullet</li>
</ol>
        '''.strip()
        result = markdown3.to_html(data).strip()
        assert expected == result
Example #11
0
    def test_paragraphs_in_bullet(self):
        "Test that spaced out bullets add paragraphs"
        data = """
1. A numbered bullet

2. Another numbered bullet

3. Yet another bullet
"""

        expected = [
            'body',
            ['ordered_list',
             ['numbered_bullet_with_paragraph',
              ['paragraph',
               ['plain', "A numbered bullet"]]],
             ['numbered_bullet_with_paragraph',
              ['paragraph',
               ['plain', "Another numbered bullet"]]],
             ['numbered_bullet_with_paragraph',
              ['paragraph',
               ['plain', "Yet another bullet"]]]]]

        result = markdown3.parse(data)
        assert expected == result

        expected = '''
<ol>
  <li><p>A numbered bullet</p></li>
  <li><p>Another numbered bullet</p></li>
  <li><p>Yet another bullet</p></li>
</ol>'''.strip()

        result = markdown3.to_html(data)
        assert expected == result
Example #12
0
def test_title_level_2():
    data = """
## A level two title ##
"""
    expected = ['body', ['title_level_2', "A level two title "]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<h2>A level two title </h2>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result

    # Without linebreaks

    data = """
## A level two title
""".strip()
    expected = ['body', ['title_level_2', "A level two title"]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<h2>A level two title</h2>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result

    # With extra linebreaks

    data = """

## A level two title
"""
    expected = ['body', ['title_level_2', "A level two title"]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<h2>A level two title</h2>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #13
0
def test_body():
    data = "Hello World"
    expected = ['body', ['paragraph', ['plain', "Hello World"]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = """
<p>Hello World</p>
    """.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #14
0
def test_plain():
    data = "Name: Mr Flibble"
    expected = ['body', ['paragraph', ['plain', "Name: Mr Flibble"]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = """
<p>Name: Mr Flibble</p>
    """.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #15
0
def test_link():
    data = "[a link to Google with * in it](http://www.google.com)"
    expected = [
        'body',
        [
            'paragraph',
            [
                'link', ['link_text', "a link to Google with * in it"],
                ['link_url', "http://www.google.com"]
            ]
        ]
    ]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p><a href="http://www.google.com">a link to Google with * in it</a></p>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result

    data = "Text with [a link to Google](http://www.google.com) in it"
    expected = [
        'body',
        [
            'paragraph', ['plain', "Text with "],
            [
                'link', ['link_text', "a link to Google"],
                ['link_url', "http://www.google.com"]
            ], ['plain', " in it"]
        ]
    ]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p>Text with <a href="http://www.google.com">a link to Google</a> in it</p>
    '''.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #16
0
def test_nested_bullets():
    data = """
1. A numbered bullet
  2. A bullet in a sublist
  3. A bullet with *bold* in a sublist
4. A bullet with `code` in the first list
"""

    expected = [
        'body',
        [
            'ordered_list',
            [
                'numbered_bullet_without_paragraph',
                ['plain', "A numbered bullet"]
            ],
            [
                'ordered_list_nested',
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "A bullet in a sublist"]
                ],
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "A bullet with "], ['emphasis', "bold"],
                    ['plain', " in a sublist"]
                ]
            ],
            [
                'numbered_bullet_without_paragraph',
                ['plain', "A bullet with "], ['code', "code"],
                ['plain', " in the first list"]
            ]
        ]
    ]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<ol>
  <li>A numbered bullet</li>
  <ol>
    <li>A bullet in a sublist</li>
    <li>A bullet with <strong>bold</strong> in a sublist</li>
  </ol>
  
  <li>A bullet with <code>code</code> in the first list</li>
</ol>
""".strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #17
0
def test_paragraph():
    data = """
A paragraph.
"""
    expected = [
        'body',
        ['paragraph',
         ['plain', "A paragraph."]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p>A paragraph.</p>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result

    data = """
A paragraph with *some bold*, `some code` and [a link to Google](http://www.google.com) in it.
"""
    expected = [
        'body',
        ['paragraph',
         ['plain', "A paragraph with "],
         ['emphasis', "some bold"],
         ['plain', ", "],
         ['code', "some code"],
         ['plain', " and "],
         ['link',
          ['link_text', "a link to Google"],
          ['link_url', "http://www.google.com"]],
         ['plain', " in it."]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p>A paragraph with <strong>some bold</strong>, <code>some code</code> and <a href="http://www.google.com">a link to Google</a> in it.</p>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #18
0
def test_body():
    data = "Hello World"
    expected = [
        'body',
        ['paragraph',
         ['plain', "Hello World"]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = """
<p>Hello World</p>
    """.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #19
0
def test_plain():
    data = "Name: Mr Flibble"
    expected = [
        'body',
        ['paragraph',
         ['plain', "Name: Mr Flibble"]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = """
<p>Name: Mr Flibble</p>
    """.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #20
0
def test_paragraph():
    data = """
A paragraph.
"""
    expected = ['body', ['paragraph', ['plain', "A paragraph."]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p>A paragraph.</p>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result

    data = """
A paragraph with *some bold*, `some code` and [a link to Google](http://www.google.com) in it.
"""
    expected = [
        'body',
        [
            'paragraph', ['plain', "A paragraph with "],
            ['emphasis', "some bold"], ['plain', ", "], ['code', "some code"],
            ['plain', " and "],
            [
                'link', ['link_text', "a link to Google"],
                ['link_url', "http://www.google.com"]
            ], ['plain', " in it."]
        ]
    ]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p>A paragraph with <strong>some bold</strong>, <code>some code</code> and <a href="http://www.google.com">a link to Google</a> in it.</p>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #21
0
def test_link():
    data = "[a link to Google with * in it](http://www.google.com)"
    expected = [
        'body',
        ['paragraph',
         ['link',
          ['link_text', "a link to Google with * in it"],
          ['link_url', "http://www.google.com"]]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p><a href="http://www.google.com">a link to Google with * in it</a></p>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result

    data = "Text with [a link to Google](http://www.google.com) in it"
    expected = [
        'body',
        ['paragraph',
         ['plain', "Text with "],
         ['link',
          ['link_text', "a link to Google"],
          ['link_url',
           "http://www.google.com"]],
         ['plain', " in it"]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p>Text with <a href="http://www.google.com">a link to Google</a> in it</p>
    '''.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #22
0
def test_code():
    data = "text with `some code` in it"
    expected = [
        'body',
        ['paragraph',
         ['plain', "text with "],
         ['code', "some code"],
         ['plain', " in it"]]]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p>text with <code>some code</code> in it</p>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #23
0
    def test_multiple_bullets(self):
        "Test that several bullets with markup in them work"
        data = """
1. A numbered bullet
2. Another numbered bullet
3. A bullet with *bold*
4. A bullet with `code`
"""

        expected = [
            'body',
            [
                'ordered_list',
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "A numbered bullet"]
                ],
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "Another numbered bullet"]
                ],
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "A bullet with "], ['emphasis', "bold"]
                ],
                [
                    'numbered_bullet_without_paragraph',
                    ['plain', "A bullet with "], ['code', "code"]
                ]
            ]
        ]

        result = markdown3.parse(data)
        assert expected == result

        expected = '''
<ol>
  <li>A numbered bullet</li>
  <li>Another numbered bullet</li>
  <li>A bullet with <strong>bold</strong></li>
  <li>A bullet with <code>code</code></li>
</ol>
        '''.strip()

        result = markdown3.to_html(data)
        assert expected == result
Example #24
0
def test_code():
    data = "text with `some code` in it"
    expected = [
        'body',
        [
            'paragraph', ['plain', "text with "], ['code', "some code"],
            ['plain', " in it"]
        ]
    ]
    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<p>text with <code>some code</code> in it</p>
    '''.strip()
    result = markdown3.to_html(data)
    assert expected == result
Example #25
0
def test_horizontal_rules():
    data = """
---

- - - -

____

_ _ _ _ _

***

* * * *
"""

    expected = [
        'body',
        [ 'horizontal_rule', "---"],
        [ 'horizontal_rule', "- - -"],
        [ 'horizontal_rule', "___"],
        [ 'horizontal_rule', "_ _ _"],
        [ 'horizontal_rule', "***"],
        [ 'horizontal_rule', "* * *"]]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<hr/>

<hr/>

<hr/>

<hr/>

<hr/>

<hr/>

    """.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #26
0
def test_nested_bullets():
    data = """
1. A numbered bullet
  2. A bullet in a sublist
  3. A bullet with *bold* in a sublist
4. A bullet with `code` in the first list
"""

    expected = [
        'body',
        ['ordered_list',
         ['numbered_bullet_without_paragraph',
          ['plain', "A numbered bullet"]],
         ['ordered_list_nested',
          ['numbered_bullet_without_paragraph',
           ['plain', "A bullet in a sublist"]],
          ['numbered_bullet_without_paragraph',
           ['plain', "A bullet with "],
           ['emphasis', "bold"],
           ['plain', " in a sublist"]]],
         ['numbered_bullet_without_paragraph',
          ['plain', "A bullet with "],
          ['code', "code"],
          ['plain', " in the first list"]]]]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<ol>
  <li>A numbered bullet</li>
  <ol>
    <li>A bullet in a sublist</li>
    <li>A bullet with <strong>bold</strong> in a sublist</li>
  </ol>
  
  <li>A bullet with <code>code</code> in the first list</li>
</ol>
""".strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #27
0
    def test_paragraphs_in_bullet(self):
        "Test that spaced out bullets add paragraphs"
        data = """
1. A numbered bullet

2. Another numbered bullet

3. Yet another bullet
"""

        expected = [
            'body',
            [
                'ordered_list',
                [
                    'numbered_bullet_with_paragraph',
                    ['paragraph', ['plain', "A numbered bullet"]]
                ],
                [
                    'numbered_bullet_with_paragraph',
                    ['paragraph', ['plain', "Another numbered bullet"]]
                ],
                [
                    'numbered_bullet_with_paragraph',
                    ['paragraph', ['plain', "Yet another bullet"]]
                ]
            ]
        ]

        result = markdown3.parse(data)
        assert expected == result

        expected = '''
<ol>
  <li><p>A numbered bullet</p></li>
  <li><p>Another numbered bullet</p></li>
  <li><p>Yet another bullet</p></li>
</ol>'''.strip()

        result = markdown3.to_html(data)
        assert expected == result
Example #28
0
def test_horizontal_rules():
    data = """
---

- - - -

____

_ _ _ _ _

***

* * * *
"""

    expected = [
        'body', ['horizontal_rule', "---"], ['horizontal_rule', "- - -"],
        ['horizontal_rule', "___"], ['horizontal_rule', "_ _ _"],
        ['horizontal_rule', "***"], ['horizontal_rule', "* * *"]
    ]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<hr/>

<hr/>

<hr/>

<hr/>

<hr/>

<hr/>

    """.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #29
0
def test_quoted_paragraph():
    data = """
> A quoted paragraph
"""

    expected = [
        'body', ['blockquote', ['paragraph', ['plain', "A quoted paragraph"]]]
    ]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<blockquote>
  <p>A quoted paragraph</p>
  
</blockquote>
    """.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #30
0
    def test_indented(self):
        "Test that an indented bullet works"
        data = """
    1. An indented numbered bullet"""

        expected = [
            'body',
            ['ordered_list',
             ['numbered_bullet_without_paragraph',
              ['plain', "An indented numbered bullet"]]]]

        result = markdown3.parse(data)
        assert expected == result

        expected = '''
<ol>
  <li>An indented numbered bullet</li>
</ol>
        '''.strip()
        result = markdown3.to_html(data)
        assert expected == result
Example #31
0
def test_unordered_list_advanced():
    data = """
* A bullet
* Another bullet
* A bullet with *bold*
* A bullet with `code`
"""

    expected = [
        'body',
        [
            'unordered_list',
            ['bullet_without_paragraph', ['plain', "A bullet"]],
            ['bullet_without_paragraph', ['plain', "Another bullet"]],
            [
                'bullet_without_paragraph', ['plain', "A bullet with "],
                ['emphasis', "bold"]
            ],
            [
                'bullet_without_paragraph', ['plain', "A bullet with "],
                ['code', "code"]
            ]
        ]
    ]

    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<ul>
  <li>A bullet</li>
  <li>Another bullet</li>
  <li>A bullet with <strong>bold</strong></li>
  <li>A bullet with <code>code</code></li>
</ul>
    '''.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #32
0
    def test_tab_indentation(self):
        data = """
	1. Bullet One
	2. Bullet Two"""

        expected = [
            'body',
            ['ordered_list',
             ['numbered_bullet_without_paragraph',
              ['plain', "Bullet One"]],
             ['numbered_bullet_without_paragraph',
              ['plain', "Bullet Two"]]]]

        result = markdown3.parse(data)
        assert expected == result

        expected = """
<ol>
  <li>Bullet One</li>
  <li>Bullet Two</li>
</ol>""".strip()
        result = markdown3.to_html(data)
        assert expected == result
Example #33
0
    def test_multiple_bullets(self):
        "Test that several bullets with markup in them work"
        data = """
1. A numbered bullet
2. Another numbered bullet
3. A bullet with *bold*
4. A bullet with `code`
"""

        expected = [
            'body',
            ['ordered_list',
             ['numbered_bullet_without_paragraph',
              ['plain', "A numbered bullet"]],
             ['numbered_bullet_without_paragraph',
              ['plain', "Another numbered bullet"]],
             ['numbered_bullet_without_paragraph',
              ['plain', "A bullet with "],
              ['emphasis', "bold"]],
             ['numbered_bullet_without_paragraph',
              ['plain', "A bullet with "],
              ['code', "code"]]]]

        result = markdown3.parse(data)
        assert expected == result

        expected = '''
<ol>
  <li>A numbered bullet</li>
  <li>Another numbered bullet</li>
  <li>A bullet with <strong>bold</strong></li>
  <li>A bullet with <code>code</code></li>
</ol>
        '''.strip()

        result = markdown3.to_html(data)
        assert expected == result
Example #34
0
def test_quoted_paragraph():
    data = """
> A quoted paragraph
"""

    expected = [
        'body',
        ['blockquote',
         ['paragraph',
          ['plain',
           "A quoted paragraph"]]]]

    result = markdown3.parse(data)
    assert expected == result

    expected = """
<blockquote>
  <p>A quoted paragraph</p>
  
</blockquote>
    """.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #35
0
    def test_tab_indentation(self):
        data = """
	1. Bullet One
	2. Bullet Two"""

        expected = [
            'body',
            [
                'ordered_list',
                ['numbered_bullet_without_paragraph', ['plain', "Bullet One"]],
                ['numbered_bullet_without_paragraph', ['plain', "Bullet Two"]]
            ]
        ]

        result = markdown3.parse(data)
        assert expected == result

        expected = """
<ol>
  <li>Bullet One</li>
  <li>Bullet Two</li>
</ol>""".strip()
        result = markdown3.to_html(data)
        assert expected == result
Example #36
0
def test_unordered_list_advanced():
    data = """
* A bullet
* Another bullet
* A bullet with *bold*
* A bullet with `code`
"""

    expected = [
        'body',
        ['unordered_list',
         ['bullet_without_paragraph',
          ['plain', "A bullet"]],
         ['bullet_without_paragraph',
          ['plain', "Another bullet"]],
         ['bullet_without_paragraph',
          ['plain', "A bullet with "],
          ['emphasis', "bold"]],
         ['bullet_without_paragraph',
          ['plain', "A bullet with "],
          ['code', "code"]]]]

    result = markdown3.parse(data)
    assert expected == result

    expected = '''
<ul>
  <li>A bullet</li>
  <li>Another bullet</li>
  <li>A bullet with <strong>bold</strong></li>
  <li>A bullet with <code>code</code></li>
</ul>
    '''.strip()

    result = markdown3.to_html(data)
    assert expected == result
Example #37
0
    def do_test(data, expected_tree, expected_html):
        result = markdown3.parse(data)
        assert expected_tree == result

        result = markdown3.to_html(data)
        assert expected_html == result
Example #38
0
    def do_test(data, expected_tree, expected_html):
        result = markdown3.parse(data)
        assert expected_tree == result

        result = markdown3.to_html(data)
        assert expected_html == result