From 9fdca7919c9fd1d035117c60d1b713ae5f07a061 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 24 Mar 2022 15:32:37 +0000 Subject: [PATCH] Improve handling of markup while emboldening text --- content.py | 4 ++-- tests.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content.py b/content.py index c649e7fa8..0bf1f9273 100644 --- a/content.py +++ b/content.py @@ -1345,9 +1345,9 @@ def bold_reading_string(text: str) -> str: new_parag = '' reading_markup = False for wrd in words: - if '<' in wrd and '>' not in wrd: + if '<' in wrd: reading_markup = True - if reading_markup and '>' in wrd and '<' not in wrd: + if reading_markup and '>' in wrd: reading_markup = False if not reading_markup and len(wrd) > 1 and \ '<' not in wrd and '>' not in wrd and \ diff --git a/tests.py b/tests.py index 7cc08206a..98d4e4d4a 100644 --- a/tests.py +++ b/tests.py @@ -6721,12 +6721,12 @@ def _test_bold_reading() -> None: assert text_bold == expected text = '

This is a test with markup containing spaces

' + 'href="some_url">

' 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