Ignore target_words that are not alphanumeric

This commit is contained in:
DUO Labs 2021-10-27 07:35:33 -04:00 committed by GitHub
parent 1abd040428
commit 4e91a02a3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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>',