mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Regexp highlight / serach fix
This commit is contained in:
parent
2ab3915448
commit
a01761e729
1 changed files with 6 additions and 2 deletions
|
@ -4,8 +4,12 @@ function highlightText(text, toHighlight) {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
const re = new RegExp(toHighlight, 'gi')
|
try {
|
||||||
return text.replace(re, `<mark>${toHighlight}</mark>`)
|
const re = new RegExp(toHighlight, 'gi')
|
||||||
|
return text.replace(re, `<mark>${toHighlight}</mark>`)
|
||||||
|
} catch (e) {
|
||||||
|
return text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Question({ question, searchTerm }) {
|
export default function Question({ question, searchTerm }) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue