from markdownify import markdownify as md, ATX, ATX_CLOSED import re nested_uls = re.sub('\s+', '', """ """) 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_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* a\n* b\n\nbar' 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\t\n\t+ b\n\t+ c\n\t\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\t\n\t- b\n\t- c\n\t\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)'