#131 - Fixed highlighting for Korean queries
This commit is contained in:
@@ -6,6 +6,7 @@ export const regexLineSplit = /\r?\n|\r|((\.|\?|!)( |\r?\n|\r))/g
|
||||
export const regexYaml = /^---\s*\n(.*?)\n?^---\s?/ms
|
||||
export const regexStripQuotes = /^"|"$|^'|'$/g
|
||||
export const chsRegex = /[\u4e00-\u9fa5]/
|
||||
export const chsSegmenter = (app as any).plugins.plugins['cm-chs-patch']
|
||||
|
||||
export const excerptBefore = 100
|
||||
export const excerptAfter = 300
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
} from '../globals'
|
||||
import {
|
||||
chsRegex,
|
||||
chsSegmenter,
|
||||
indexingStep,
|
||||
IndexingStepType,
|
||||
SPACE_OR_PUNCTUATION,
|
||||
@@ -24,7 +25,6 @@ import { cacheManager } from '../cache-manager'
|
||||
|
||||
const tokenize = (text: string): string[] => {
|
||||
const tokens = text.split(SPACE_OR_PUNCTUATION)
|
||||
const chsSegmenter = (app as any).plugins.plugins['cm-chs-patch']
|
||||
|
||||
if (chsSegmenter) {
|
||||
return tokens.flatMap(word =>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from 'obsidian'
|
||||
import type { SearchMatch } from '../globals'
|
||||
import {
|
||||
chsSegmenter,
|
||||
excerptAfter,
|
||||
excerptBefore,
|
||||
highlightClass,
|
||||
@@ -70,7 +71,10 @@ export function getAllIndices(text: string, regex: RegExp): SearchMatch[] {
|
||||
*/
|
||||
export function stringsToRegex(strings: string[]): RegExp {
|
||||
if (!strings.length) return /^$/g
|
||||
const joined = strings.map(s => '\\b' + escapeRegex(s)).join('|')
|
||||
// \\b is "word boundary", and is not applied if the user uses the cm-chs-patch plugin
|
||||
const joined = strings
|
||||
.map(s => (chsSegmenter ? '' : '\\b') + escapeRegex(s))
|
||||
.join('|')
|
||||
const reg = new RegExp(`(${joined})`, 'gi')
|
||||
// console.log(reg)
|
||||
return reg
|
||||
|
||||
Reference in New Issue
Block a user