Fix errors with boldening terms

This commit is contained in:
DUO Labs 2021-10-26 17:22:52 -04:00 committed by GitHub
parent 6763c2e99d
commit fe8bfa655a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,15 +53,7 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup:
# Replace all instances of the word, but maintaining the same case in
# the replacement
element.replace_with(
element.replace(
target_word.lower(), f'<b>{target_word.lower()}</b>'
).replace(
target_word.capitalize(), f'<b>{target_word.capitalize()}</b>'
).replace(
target_word.title(), f'<b>{target_word.title()}</b>'
).replace(
target_word.upper(), f'<b>{target_word.upper()}</b>'
)
re.sub(fr"\b({target_word})\b",r"<b>\1</b>",element,flags=re.I)
)
# Split all words out of query, grouping the ones wrapped in quotes