Spaces:
Running
on
L4
Running
on
L4
liamcripwell
commited on
Commit
•
9357e9c
1
Parent(s):
1d15344
escape pattern value
Browse files
app.py
CHANGED
@@ -60,7 +60,7 @@ def highlight_words(input_text, json_output):
|
|
60 |
color = color_map[path_key]
|
61 |
# highlighted_text = highlighted_text.replace(f" {value}", f" <span style='background-color: {color};'>{unquote(f'{value}')}</span>")
|
62 |
|
63 |
-
pattern = rf"(?<=[ \n\t]){value}(?=[ \n\t\.\,\?\:\;])"
|
64 |
replacement = f"<span style='background-color: {color};'>{unquote(value)}</span>"
|
65 |
highlighted_text = re.sub(pattern, replacement, highlighted_text, flags=re.IGNORECASE)
|
66 |
|
|
|
60 |
color = color_map[path_key]
|
61 |
# highlighted_text = highlighted_text.replace(f" {value}", f" <span style='background-color: {color};'>{unquote(f'{value}')}</span>")
|
62 |
|
63 |
+
pattern = rf"(?<=[ \n\t]){re.escape(value)}(?=[ \n\t\.\,\?\:\;])"
|
64 |
replacement = f"<span style='background-color: {color};'>{unquote(value)}</span>"
|
65 |
highlighted_text = re.sub(pattern, replacement, highlighted_text, flags=re.IGNORECASE)
|
66 |
|