Skip to content

Commit

Permalink
Fixed #195
Browse files Browse the repository at this point in the history
  • Loading branch information
scambier committed Feb 24, 2023
1 parent 1c1b72f commit d6b4d65
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ export function highlighter(str: string): string {
}

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 '&lt;no content&gt;'
}
Expand Down Expand Up @@ -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
const joined =
'(' +
(getChsSegmenter() ? '' : SPACE_OR_PUNCTUATION.source) +
(getChsSegmenter() ? '' : `^|${SPACE_OR_PUNCTUATION.source}`) +
')' +
'(' +
strings.map(s => escapeRegex(s)).join('|') +
Expand Down

0 comments on commit d6b4d65

Please sign in to comment.