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