mirror of https://gitlab.com/bashrc2/epicyon
Avoid emboldening spaces within markup
parent
4ea1f7e1bd
commit
ea6520c7fb
|
@ -1338,8 +1338,13 @@ def bold_reading_string(text: str) -> str:
|
|||
for parag in paragraphs:
|
||||
words = parag.split(' ')
|
||||
new_parag = ''
|
||||
reading_markup = False
|
||||
for wrd in words:
|
||||
if len(wrd) > 1 and \
|
||||
if '<' in wrd and '>' not in wrd:
|
||||
reading_markup = True
|
||||
if reading_markup and '>' in wrd and '<' not in wrd:
|
||||
reading_markup = False
|
||||
if not reading_markup and len(wrd) > 1 and \
|
||||
'<' not in wrd and '>' not in wrd and \
|
||||
not wrd.startswith(':'):
|
||||
|
||||
|
|
11
tests.py
11
tests.py
|
@ -6720,6 +6720,17 @@ def _test_bold_reading() -> None:
|
|||
print(text_bold)
|
||||
assert text_bold == expected
|
||||
|
||||
text = '<p>This is a test <a class="some class" ' + \
|
||||
'href="some_url">with markup containing spaces</a><p>'
|
||||
text_bold = bold_reading_string(text)
|
||||
expected = \
|
||||
'<p><b>Th</b>is <b>i</b>s a <b>te</b>st ' + \
|
||||
'<a class="some class" href="some_url">with ' + \
|
||||
'<b>mar</b>kup <b>conta</b>ining spaces</a></p>'
|
||||
if text_bold != expected:
|
||||
print(text_bold)
|
||||
assert text_bold == expected
|
||||
|
||||
|
||||
def run_all_tests():
|
||||
base_dir = os.getcwd()
|
||||
|
|
Loading…
Reference in New Issue