Fix unit tests

main
Bob Mottram 2022-06-27 17:21:48 +01:00
parent 7d4addfac8
commit 3e2e7f25bf
6 changed files with 26 additions and 19 deletions

View File

@ -313,7 +313,7 @@ def _html_blog_post_content(debug: bool, session, authorized: bool,
if citations_str: if citations_str:
citations_str = '<p><b>' + translate['Citations'] + \ citations_str = '<p><b>' + translate['Citations'] + \
':</b></p>' + \ ':</b></p>' + \
'<ul>\n' + citations_str + '</ul>\n' '<u>\n' + citations_str + '</u>\n'
blog_str += '<br>\n' + citations_str blog_str += '<br>\n' + citations_str

View File

@ -256,6 +256,10 @@ code {
line-height: var(--code-spacing); line-height: var(--code-spacing);
} }
ul.md_list {
color: var(--main-fg-color);
}
audio { audio {
width: 100%; width: 100%;
} }

View File

@ -68,13 +68,13 @@ def _markdown_emphasis_html(markdown: str) -> str:
'*)': '</i>)', '*)': '</i>)',
'*,': '</i>,', '*,': '</i>,',
'*\n': '</i>\n', '*\n': '</i>\n',
' _': ' <ul>', ' _': ' <u>',
'_ ': '</ul> ', '_ ': '</u> ',
'_.': '</ul>.', '_.': '</u>.',
'_:': '</ul>:', '_:': '</u>:',
'_;': '</ul>;', '_;': '</u>;',
'_,': '</ul>,', '_,': '</u>,',
'_\n': '</ul>\n', '_\n': '</u>\n',
' `': ' <em>', ' `': ' <em>',
'`.': '</em>.', '`.': '</em>.',
'`:': '</em>:', '`:': '</em>:',
@ -100,14 +100,14 @@ def _markdown_emphasis_html(markdown: str) -> str:
elif section_text.startswith('*'): elif section_text.startswith('*'):
section_text = section_text[1:] + '<i>' section_text = section_text[1:] + '<i>'
elif section_text.startswith('_'): elif section_text.startswith('_'):
section_text = section_text[1:] + '<ul>' section_text = section_text[1:] + '<u>'
if section_text.endswith('**'): if section_text.endswith('**'):
section_text = section_text[:len(section_text) - 2] + '</b>' section_text = section_text[:len(section_text) - 2] + '</b>'
elif section_text.endswith('*'): elif section_text.endswith('*'):
section_text = section_text[:len(section_text) - 1] + '</i>' section_text = section_text[:len(section_text) - 1] + '</i>'
elif section_text.endswith('_'): elif section_text.endswith('_'):
section_text = section_text[:len(section_text) - 1] + '</ul>' section_text = section_text[:len(section_text) - 1] + '</u>'
if section_text.strip(): if section_text.strip():
markdown += section_text markdown += section_text
@ -259,7 +259,8 @@ def _markdown_replace_bullet_points(markdown: str) -> str:
for index in range(start_line, line_ctr): for index in range(start_line, line_ctr):
line_text = lines[index].replace(bullet_matched, '', 1) line_text = lines[index].replace(bullet_matched, '', 1)
if index == start_line: if index == start_line:
lines[index] = '<ul>\n<li>' + line_text + '</li>' lines[index] = \
'<ul class="md_list">\n<li>' + line_text + '</li>'
elif index == line_ctr - 1: elif index == line_ctr - 1:
lines[index] = '<li>' + line_text + '</li>\n</ul>' lines[index] = '<li>' + line_text + '</li>\n</ul>'
else: else:

View File

@ -5736,7 +5736,8 @@ 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>\n<ul><br>\n<li>Point 1</li><br>\n' + \ 'This is a list of points:<br>\n<ul class="md_list">' + \
'<br>\n<li>Point 1</li><br>\n' + \
'<li>Point 2</li><br>\n<li></li><br>\n</ul><br>\n' + \ '<li>Point 2</li><br>\n<li></li><br>\n</ul><br>\n' + \
'And some other text.<br>\n' 'And some other text.<br>\n'
if result != expected: if result != expected:
@ -5749,7 +5750,7 @@ 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>\n<ul><br>\n' + \ 'This is a list of points:<br>\n<ul class="md_list"><br>\n' + \
'<li><b>Point 1</b></li><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' + \ '<li><i>Point 2</i></li><br>\n<li></li><br>\n</ul><br>\n' + \
'And some other text.<br>\n' 'And some other text.<br>\n'
@ -5767,10 +5768,11 @@ def _test_markdown_to_html():
expected = \ expected = \
'This is a code section:<br>\n' + \ 'This is a code section:<br>\n' + \
'<code>\n' + \ '<code>\n' + \
'10 PRINT "YOLO"<br>\n' + \ '10 PRINT "YOLO"\n' + \
'20 GOTO 10<br>\n' + \ '20 GOTO 10\n' + \
'</code>\n' + \ '</code>\n' + \
'<br>\nAnd some other text.<br>\n' '<br>\n' + \
'And some other text.<br>\n'
if result != expected: if result != expected:
print(result) print(result)
assert result == expected assert result == expected
@ -5782,7 +5784,7 @@ def _test_markdown_to_html():
assert markdown_to_html(markdown) == 'This is <i>italic</i>' assert markdown_to_html(markdown) == 'This is <i>italic</i>'
markdown = 'This is _underlined_' markdown = 'This is _underlined_'
assert markdown_to_html(markdown) == 'This is <ul>underlined</ul>' assert markdown_to_html(markdown) == 'This is <u>underlined</u>'
markdown = 'This is **just** plain text' markdown = 'This is **just** plain text'
assert markdown_to_html(markdown) == 'This is <b>just</b> plain text' assert markdown_to_html(markdown) == 'This is <b>just</b> plain text'

View File

@ -102,7 +102,7 @@ def _html_podcast_chapters(link_url: str,
if chapters_html: if chapters_html:
html_str = \ html_str = \
'<div class="chapters">\n' + \ '<div class="chapters">\n' + \
' <ul>\n' + chapters_html + ' </ul>\n</div>\n' ' <u>\n' + chapters_html + ' </u>\n</div>\n'
return html_str return html_str

View File

@ -1008,7 +1008,7 @@ def _get_blog_citations_html(box_name: str,
if translate.get(translated_citations_str): if translate.get(translated_citations_str):
translated_citations_str = translate[translated_citations_str] translated_citations_str = translate[translated_citations_str]
citations_str = '<p><b>' + translated_citations_str + ':</b></p>' + \ citations_str = '<p><b>' + translated_citations_str + ':</b></p>' + \
'<ul>\n' + citations_str + '</ul>\n' '<u>\n' + citations_str + '</u>\n'
return citations_str return citations_str