Merge branch 'andrewcrichards/add_code_samp_kbd_tags' of https://github.com/AndrewCRichards/python-markdownify into AndrewCRichards-andrewcrichards/add_code_samp_kbd_tags
This commit is contained in:
@@ -14,3 +14,10 @@ def test_ignore_comments():
|
||||
def test_ignore_comments_with_other_tags():
|
||||
text = md("<!-- This is a comment --><a href='http://example.com/'>example link</a>")
|
||||
assert text == "[example link](http://example.com/)"
|
||||
|
||||
|
||||
def test_code_with_tricky_content():
|
||||
assert md('<code>></code>') == "`>`"
|
||||
assert md('<code>/home/</code><b>username</b>') == "`/home/`**username**"
|
||||
assert md('First line <code>blah blah<br />blah blah</code> second line') \
|
||||
== "First line `blah blah \nblah blah` second line"
|
||||
|
||||
@@ -240,6 +240,27 @@ def test_em_spaces():
|
||||
assert md('foo <em></em> bar') == 'foo bar'
|
||||
|
||||
|
||||
def code_samp_kbd_tests(tag):
|
||||
# Basically re-use test_em() and test_em_spaces(),
|
||||
assert md(f'<{tag}>Hello</{tag}>') == '`Hello`'
|
||||
assert md(f'foo <{tag}>Hello</{tag}> bar') == 'foo `Hello` bar'
|
||||
assert md(f'foo<{tag}> Hello</{tag}> bar') == 'foo `Hello` bar'
|
||||
assert md(f'foo <{tag}>Hello </{tag}>bar') == 'foo `Hello` bar'
|
||||
assert md(f'foo <{tag}></{tag}> bar') in ['foo bar', 'foo bar'] # Either is OK
|
||||
|
||||
|
||||
def test_code():
|
||||
code_samp_kbd_tests('code')
|
||||
|
||||
|
||||
def test_samp():
|
||||
code_samp_kbd_tests('samp')
|
||||
|
||||
|
||||
def test_kbd():
|
||||
code_samp_kbd_tests('kbd')
|
||||
|
||||
|
||||
def test_h1():
|
||||
assert md('<h1>Hello</h1>') == 'Hello\n=====\n\n'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user