mirror of https://gitlab.com/bashrc2/epicyon
Fix markdown tests
parent
8d68794ae7
commit
8585152321
|
@ -19,6 +19,10 @@ def _markdown_emphasis_html(markdown: str) -> str:
|
|||
'**;': '</b>;',
|
||||
'**,': '</b>,',
|
||||
'**\n': '</b>\n',
|
||||
'>**': '><b>',
|
||||
'**<': '</b><',
|
||||
'>*': '><i>',
|
||||
'*<': '</i><',
|
||||
' *': ' <i>',
|
||||
'* ': '</i> ',
|
||||
'*.': '</i>.',
|
||||
|
@ -302,4 +306,8 @@ def markdown_to_html(markdown: str) -> str:
|
|||
break
|
||||
html_str += line
|
||||
ctr += 1
|
||||
|
||||
html_str = html_str.replace('<code><br>', '<code>')
|
||||
html_str = html_str.replace('</code><br>', '</code>')
|
||||
|
||||
return html_str
|
||||
|
|
47
tests.py
47
tests.py
|
@ -5715,14 +5715,19 @@ def _test_markdown_to_html():
|
|||
|
||||
markdown = 'This is a quotation:\n' + \
|
||||
'> Some quote or other'
|
||||
assert markdown_to_html(markdown) == 'This is a quotation:<br>' + \
|
||||
expected = \
|
||||
'This is a quotation:<br>\n' + \
|
||||
'<blockquote><i>Some quote or other</i></blockquote>'
|
||||
result = markdown_to_html(markdown)
|
||||
if result != expected:
|
||||
print(result)
|
||||
assert result == expected
|
||||
|
||||
markdown = 'This is a multi-line quotation:\n' + \
|
||||
'> The first line\n' + \
|
||||
'> The second line'
|
||||
assert markdown_to_html(markdown) == \
|
||||
'This is a multi-line quotation:<br>' + \
|
||||
'This is a multi-line quotation:<br>\n' + \
|
||||
'<blockquote><i>The first line The second line</i></blockquote>'
|
||||
|
||||
markdown = 'This is a list of points:\n' + \
|
||||
|
@ -5731,8 +5736,23 @@ def _test_markdown_to_html():
|
|||
'And some other text.'
|
||||
result = markdown_to_html(markdown)
|
||||
expected = \
|
||||
'This is a list of points:<br><ul><br><li>Point 1</li><br>' + \
|
||||
'<li>Point 2</li><br><li></li><br></ul><br>And some other text.<br>'
|
||||
'This is a list of points:<br>\n<ul><br>\n<li>Point 1</li><br>\n' + \
|
||||
'<li>Point 2</li><br>\n<li></li><br>\n</ul><br>\n' + \
|
||||
'And some other text.<br>\n'
|
||||
if result != expected:
|
||||
print(result)
|
||||
assert result == expected
|
||||
|
||||
markdown = 'This is a list of points:\n' + \
|
||||
' * **Point 1**\n' + \
|
||||
' * *Point 2*\n\n' + \
|
||||
'And some other text.'
|
||||
result = markdown_to_html(markdown)
|
||||
expected = \
|
||||
'This is a list of points:<br>\n<ul><br>\n' + \
|
||||
'<li><b>Point 1</b></li><br>\n' + \
|
||||
'<li><i>Point 2</i></li><br>\n<li></li><br>\n</ul><br>\n' + \
|
||||
'And some other text.<br>\n'
|
||||
if result != expected:
|
||||
print(result)
|
||||
assert result == expected
|
||||
|
@ -5745,8 +5765,12 @@ def _test_markdown_to_html():
|
|||
'And some other text.'
|
||||
result = markdown_to_html(markdown)
|
||||
expected = \
|
||||
'This is a code section:<br><code><br>10 PRINT "YOLO"<br>' + \
|
||||
'20 GOTO 10<br></code><br><br>And some other text.<br>'
|
||||
'This is a code section:<br>\n' + \
|
||||
'<code>\n' + \
|
||||
'10 PRINT "YOLO"<br>\n' + \
|
||||
'20 GOTO 10<br>\n' + \
|
||||
'</code>\n' + \
|
||||
'<br>\nAnd some other text.<br>\n'
|
||||
if result != expected:
|
||||
print(result)
|
||||
assert result == expected
|
||||
|
@ -5764,8 +5788,11 @@ def _test_markdown_to_html():
|
|||
assert markdown_to_html(markdown) == 'This is <b>just</b> plain text'
|
||||
|
||||
markdown = '# Title1\n### Title3\n## Title2\n'
|
||||
assert markdown_to_html(markdown) == \
|
||||
'<h1>Title1</h1><h3>Title3</h3><h2>Title2</h2>'
|
||||
expected = '<h1>Title1</h1>\n<h3>Title3</h3>\n<h2>Title2</h2>\n'
|
||||
result = markdown_to_html(markdown)
|
||||
if result != expected:
|
||||
print(result)
|
||||
assert result == expected
|
||||
|
||||
markdown = \
|
||||
'This is [a link](https://something.somewhere) to something.\n' + \
|
||||
|
@ -5774,10 +5801,10 @@ def _test_markdown_to_html():
|
|||
expected = \
|
||||
'This is <a href="https://something.somewhere" ' + \
|
||||
'target="_blank" rel="nofollow noopener noreferrer">' + \
|
||||
'a link</a> to something.<br>' + \
|
||||
'a link</a> to something.<br>\n' + \
|
||||
'And <a href="https://cat.pic" ' + \
|
||||
'target="_blank" rel="nofollow noopener noreferrer">' + \
|
||||
'something else</a>.<br>' + \
|
||||
'something else</a>.<br>\n' + \
|
||||
'Or <img class="markdownImage" src="/cat.jpg" alt="pounce" />.'
|
||||
result = markdown_to_html(markdown)
|
||||
if result != expected:
|
||||
|
|
Loading…
Reference in New Issue