Ignore target_words that are not alphanumeric
This commit is contained in:
parent
1abd040428
commit
4e91a02a3e
|
@ -51,7 +51,10 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup:
|
||||||
# the replacement
|
# the replacement
|
||||||
if len(element) == len(target_word):
|
if len(element) == len(target_word):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not target_word.isalnum():
|
||||||
|
return
|
||||||
|
|
||||||
element.replace_with(
|
element.replace_with(
|
||||||
re.sub(fr'\b((?![{{}}<>-]){target_word}(?![{{}}<>-]))\b',
|
re.sub(fr'\b((?![{{}}<>-]){target_word}(?![{{}}<>-]))\b',
|
||||||
r'<b>\1</b>',
|
r'<b>\1</b>',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user