Updated webutils.highlight_content to ignore double-quotes when highlighting query parts

This commit is contained in:
Daniel Hones 2021-02-08 23:58:54 -05:00
parent ab8739809c
commit 138f32471c
3 changed files with 27 additions and 2 deletions

View file

@ -119,7 +119,10 @@ def highlight_content(content, query):
else:
regex_parts = []
for chunk in query.split():
if len(chunk) == 1:
chunk = chunk.replace('"', '')
if len(chunk) == 0:
continue
elif len(chunk) == 1:
regex_parts.append('\\W+{0}\\W+'.format(re.escape(chunk)))
else:
regex_parts.append('{0}'.format(re.escape(chunk)))