We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56c7b72 commit 13a748cCopy full SHA for 13a748c
1 file changed
components/hearing/Transcriptions.tsx
@@ -289,10 +289,17 @@ const TranscriptItem = forwardRef(function TranscriptItem(
289
}
290
const highlightText = (text: string, term: string) => {
291
if (!term) return text
292
- const regex = new RegExp(`(${term})`, "gi")
293
- return text
294
- .split(regex)
295
- .map((part, i) => (regex.test(part) ? <mark key={i}>{part}</mark> : part))
+ const escaped = term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
+ const regex = new RegExp(`(${escaped})`, "gi")
+ return text.split(regex).map((part, i) =>
+ regex.test(part) ? (
296
+ <mark key={i} className={`p-0`}>
297
+ {part}
298
+ </mark>
299
+ ) : (
300
+ part
301
+ )
302
303
304
305
return (
0 commit comments