This commit is contained in:
Simon Cambier
2023-02-24 22:44:26 +01:00
parent 1c1b72f32d
commit d6b4d65611

View File

@@ -27,7 +27,12 @@ export function highlighter(str: string): string {
} }
export function highlighterGroups(...args: any[]) { export function highlighterGroups(...args: any[]) {
if (args[1] && args[2]) if (
args[1] !== null &&
args[1] !== undefined &&
args[2] !== null &&
args[2] !== undefined
)
return `${args[1]}<span class="${highlightClass}">${args[2]}</span>` return `${args[1]}<span class="${highlightClass}">${args[2]}</span>`
return '&lt;no content&gt;' return '&lt;no content&gt;'
} }
@@ -88,7 +93,7 @@ export function stringsToRegex(strings: string[]): RegExp {
// Default word split is not applied if the user uses the cm-chs-patch plugin // Default word split is not applied if the user uses the cm-chs-patch plugin
const joined = const joined =
'(' + '(' +
(getChsSegmenter() ? '' : SPACE_OR_PUNCTUATION.source) + (getChsSegmenter() ? '' : `^|${SPACE_OR_PUNCTUATION.source}`) +
')' + ')' +
'(' + '(' +
strings.map(s => escapeRegex(s)).join('|') + strings.map(s => escapeRegex(s)).join('|') +