diff --git a/content.py b/content.py index c8000411a..77391ce5a 100644 --- a/content.py +++ b/content.py @@ -1334,12 +1334,17 @@ def bold_reading_string(text: str) -> str: add_paragraph_markup = True paragraphs = text.split('\n') parag_ctr = 0 - new_text = '' + new_text = '' 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(':'): diff --git a/tests.py b/tests.py index 838c669d1..fb4ef453c 100644 --- a/tests.py +++ b/tests.py @@ -6720,6 +6720,17 @@ def _test_bold_reading() -> None: print(text_bold) assert text_bold == expected + text = '
This is a test with markup containing spaces
' + text_bold = bold_reading_string(text) + expected = \ + '
This is a test ' + \ + 'with ' + \ + 'markup containing spaces
' + if text_bold != expected: + print(text_bold) + assert text_bold == expected + def run_all_tests(): base_dir = os.getcwd()