Update "skip bolding" regex to fix some edge cases (#500)

Should address errors caused by the "bold query" feature replacing
tags and style elements, resulting in unformatted response pages.
main
DUO Labs 2021-10-28 14:54:27 -04:00 committed by GitHub
parent f04c7c5557
commit 5189cdb072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -52,7 +52,8 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup:
if len(element) == len(target_word): if len(element) == len(target_word):
return return
if not target_word.isalnum(): if not re.match('.*[a-zA-Z0-9].*', target_word) or (
element.parent and element.parent.name == 'style'):
return return
element.replace_with( element.replace_with(