diff --git a/markdown.py b/markdown.py index 9bb7cafe2..24908768b 100644 --- a/markdown.py +++ b/markdown.py @@ -19,6 +19,10 @@ def _markdown_emphasis_html(markdown: str) -> str: '**;': ';', '**,': ',', '**\n': '\n', + '>**': '>', + '**<': '<', + '>*': '>', + '*<': '<', ' *': ' ', '* ': ' ', '*.': '.', @@ -302,4 +306,8 @@ def markdown_to_html(markdown: str) -> str: break html_str += line ctr += 1 + + html_str = html_str.replace('
', '') + html_str = html_str.replace('
', '
') + return html_str diff --git a/tests.py b/tests.py index b35654c49..c9278b735 100644 --- a/tests.py +++ b/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:
' + \ + expected = \ + 'This is a quotation:
\n' + \ '
Some quote or other
' + 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:
' + \ + 'This is a multi-line quotation:
\n' + \ '
The first line The second line
' 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:

And some other text.
' + 'This is a list of points:
\n
\n' + \ + 'And some other text.
\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:
\n
\n' + \ + 'And some other text.
\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:

10 PRINT "YOLO"
' + \ - '20 GOTO 10


And some other text.
' + 'This is a code section:
\n' + \ + '\n' + \ + '10 PRINT "YOLO"
\n' + \ + '20 GOTO 10
\n' + \ + '
\n' + \ + '
\nAnd some other text.
\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 just plain text' markdown = '# Title1\n### Title3\n## Title2\n' - assert markdown_to_html(markdown) == \ - '

Title1

Title3

Title2

' + expected = '

Title1

\n

Title3

\n

Title2

\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 link to something.
' + \ + 'a link to something.
\n' + \ 'And ' + \ - 'something else.
' + \ + 'something else.
\n' + \ 'Or pounce.' result = markdown_to_html(markdown) if result != expected: