Hello') == '\n> Hello\n\n' assert md('
\nHello\n') == '\n> Hello\n\n' def test_blockquote_with_nested_paragraph(): assert md('
') == '\n> Hello\n\n' assert md('Hello
') == '\n> Hello\n> \n> Hello again\n\n' def test_blockquote_with_paragraph(): assert md('Hello
Hello again
Hello
handsome
') == '\n> Hello\n\nhandsome\n\n' def test_blockquote_nested(): text = md('And she was like') assert text == '\n> And she was like \n> > Hello\n\n' def test_br(): assert md('aHello
*this_should_not_escape*') == '`*this_should_not_escape*`'
assert md('*this_should_not_escape*') == '`*this_should_not_escape*`'
assert md('*this_should_not_escape*') == '`*this_should_not_escape*`'
assert md('*this_should_not_escape*') == '`*this_should_not_escape*`'
assert md('this should\t\tnormalize') == '`this should normalize`'
assert md('this should\t\tnormalize') == '`this should normalize`'
def test_del():
inline_tests('del', '~~')
def test_div():
assert md('Hello World') == 'Hello World'
def test_em():
inline_tests('em', '*')
def test_header_with_space():
assert md('P
C ', heading_style=ATX_CLOSED) == '# A P C #\n\n' assert md('P
C ', heading_style=ATX) == '# A P C\n\n' def test_hn_nested_simple_tag(): tag_to_markdown = [ ("strong", "**strong**"), ("b", "**b**"), ("em", "*em*"), ("i", "*i*"), ("p", "p"), ("a", "a"), ("div", "div"), ("blockquote", "blockquote"), ] for tag, markdown in tag_to_markdown: assert md('
B
BHello
\nWorld
') == 'Hello\n\n\n\n\n---\n\n\nWorld\n\n' def test_i(): assert md('Hello') == '*Hello*' def test_img(): assert md('
') == ''
assert md('
') == ''
def test_kbd():
inline_tests('kbd', '`')
def test_p():
assert md('hello
') == 'hello\n\n' assert md('123456789 123456789
') == '123456789 123456789\n\n' assert md('123456789 123456789
', wrap=True, wrap_width=10) == '123456789\n123456789\n\n' assert md('', wrap=True, wrap_width=10) == '[Some long\nlink](https://example.com)\n\n' assert md('12345
67890
12345678901
12345
test\n foo\nbar') == '\n```\ntest\n foo\nbar\n```\n' assert md('
test\n foo\nbar') == '\n```\ntest\n foo\nbar\n```\n'
assert md('*this_should_not_escape*') == '\n```\n*this_should_not_escape*\n```\n' assert md('
*this_should_not_escape*') == '\n```\n*this_should_not_escape*\n```\n'
assert md('\t\tthis should\t\tnot normalize') == '\n```\n\t\tthis should\t\tnot normalize\n```\n' assert md('
\t\tthis should\t\tnot normalize') == '\n```\n\t\tthis should\t\tnot normalize\n```\n'
def test_script():
assert md('foo bar') == 'foo bar'
def test_style():
assert md('foo bar') == 'foo bar'
def test_s():
inline_tests('s', '~~')
def test_samp():
inline_tests('samp', '`')
def test_strong():
assert md('Hello') == '**Hello**'
def test_strong_em_symbol():
assert md('Hello', strong_em_symbol=UNDERSCORE) == '__Hello__'
assert md('Hello', strong_em_symbol=UNDERSCORE) == '__Hello__'
assert md('Hello', strong_em_symbol=UNDERSCORE) == '_Hello_'
assert md('Hello', strong_em_symbol=UNDERSCORE) == '_Hello_'
def test_sub():
assert md('foo') == 'foo'
assert md('foo', sub_symbol='~') == '~foo~'
def test_sup():
assert md('foo') == 'foo'
assert md('foo', sup_symbol='^') == '^foo^'
def test_lang():
assert md('test\n foo\nbar', code_language='python') == '\n```python\ntest\n foo\nbar\n```\n' assert md('
test\n foo\nbar', code_language='javascript') == '\n```javascript\ntest\n foo\nbar\n```\n'
def test_lang_callback():
def callback(el):
return el['class'][0] if el.has_attr('class') else None
assert md('test\n foo\nbar', code_language_callback=callback) == '\n```python\ntest\n foo\nbar\n```\n' assert md('
test\n foo\nbar', code_language_callback=callback) == '\n```javascript\ntest\n foo\nbar\n```\n'
assert md('test\n foo\nbar', code_language_callback=callback) == '\n```javascript\ntest\n foo\nbar\n```\n'