from markdownify import markdownify as md, ATX, ATX_CLOSED import re nested_uls = """ """ nested_ols = """
  1. 1
    1. a
      1. I
      2. II
      3. III
    2. b
    3. c
  2. 2
  3. 3
  4. """ def test_a(): assert md('Google') == '[Google](http://google.com)' def test_a_with_title(): text = md('Google') assert text == r'[Google](http://google.com "The \"Goog\"")' def test_a_shortcut(): text = md('http://google.com') assert text == '' def test_a_no_autolinks(): text = md('http://google.com', autolinks=False) assert text == '[http://google.com](http://google.com)' def test_b(): assert md('Hello') == '**Hello**' def test_blockquote(): assert md('
    Hello
    ').strip() == '> Hello' def test_nested_blockquote(): text = md('
    And she was like
    Hello
    ').strip() assert text == '> And she was like \n> > Hello' def test_br(): assert md('a
    b
    c') == 'a \nb \nc' def test_em(): assert md('Hello') == '*Hello*' def test_h1(): assert md('

    Hello

    ') == 'Hello\n=====\n\n' def test_h2(): assert md('

    Hello

    ') == 'Hello\n-----\n\n' def test_hn(): assert md('

    Hello

    ') == '### Hello\n\n' assert md('
    Hello
    ') == '###### Hello\n\n' def test_atx_headings(): assert md('

    Hello

    ', heading_style=ATX) == '# Hello\n\n' assert md('

    Hello

    ', heading_style=ATX) == '## Hello\n\n' def test_atx_closed_headings(): assert md('

    Hello

    ', heading_style=ATX_CLOSED) == '# Hello #\n\n' assert md('

    Hello

    ', heading_style=ATX_CLOSED) == '## Hello ##\n\n' def test_i(): assert md('Hello') == '*Hello*' def test_ol(): assert md('
    1. a
    2. b
    ') == '1. a\n2. b\n' def test_nested_ols(): assert md(nested_ols) == '1. 1 \n\t1. a \n\t\t1. I\n\t\t2. II\n\t\t3. III\n\t2. b\n\t3. c\n2. 2\n3. 3\n' def test_p(): assert md('

    hello

    ') == 'hello\n\n' def test_strong(): assert md('Hello') == '**Hello**' def test_ul(): assert md('') == '* a\n* b\n' def test_inline_ul(): assert md('

    foo

    bar

    ') == 'foo\n\n* a\n* b\n\nbar\n\n' def test_nested_uls(): """ Nested ULs should alternate bullet characters. """ assert md(nested_uls) == '* 1 \n\t+ a \n\t\t- I\n\t\t- II\n\t\t- III\n\t+ b\n\t+ c\n* 2\n* 3\n' def test_bullets(): assert md(nested_uls, bullets='-') == '- 1 \n\t- a \n\t\t- I\n\t\t- II\n\t\t- III\n\t- b\n\t- c\n- 2\n- 3\n' def test_img(): assert md('Alt text') == '![Alt text](/path/to/img.jpg "Optional title")' assert md('Alt text') == '![Alt text](/path/to/img.jpg)'