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:
@@ -4,8 +4,12 @@ function highlightText(text, toHighlight) {
|
|||||||
if (!text) {
|
if (!text) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const re = new RegExp(toHighlight, 'gi')
|
const re = new RegExp(toHighlight, 'gi')
|
||||||
return text.replace(re, `<mark>${toHighlight}</mark>`)
|
return text.replace(re, `<mark>${toHighlight}</mark>`)
|
||||||
|
} catch (e) {
|
||||||
|
return text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Question({ question, searchTerm }) {
|
export default function Question({ question, searchTerm }) {
|
||||||
|
Reference in New Issue
Block a user