Unescape before adding bold

main
Bob Mottram 2022-03-24 15:15:53 +00:00
parent 0f2b28ed1f
commit bca1f1c5b7
2 changed files with 10 additions and 1 deletions

View File

@ -7,6 +7,7 @@ __email__ = "bob@libreserver.org"
__status__ = "Production"
__module_group__ = "Core"
import html
import os
import email.parser
import urllib.parse
@ -1331,7 +1332,7 @@ def contains_invalid_local_links(content: str) -> bool:
def bold_reading_string(text: str) -> str:
"""Returns bold reading formatted text
"""
text = urllib.parse.unquote(text)
text = html.unescape(text)
add_paragraph_markup = False
if '<p>' in text:
text = text.replace('</p>', '\n').replace('<p>', '')

View File

@ -6731,6 +6731,14 @@ def _test_bold_reading() -> None:
print(text_bold)
assert text_bold == expected
text = "There&apos;s some quoted text here"
text_bold = bold_reading_string(text)
expected = \
"<b>The</b>re's <b>so</b>me <b>quo</b>ted <b>te</b>xt <b>he</b>re"
if text_bold != expected:
print(text_bold)
assert text_bold == expected
def run_all_tests():
base_dir = os.getcwd()