#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 regexYaml = /^---\s*\n(.*?)\n?^---\s?/ms
|
||||||
export const regexStripQuotes = /^"|"$|^'|'$/g
|
export const regexStripQuotes = /^"|"$|^'|'$/g
|
||||||
export const chsRegex = /[\u4e00-\u9fa5]/
|
export const chsRegex = /[\u4e00-\u9fa5]/
|
||||||
|
export const chsSegmenter = (app as any).plugins.plugins['cm-chs-patch']
|
||||||
|
|
||||||
export const excerptBefore = 100
|
export const excerptBefore = 100
|
||||||
export const excerptAfter = 300
|
export const excerptAfter = 300
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type {
|
|||||||
} from '../globals'
|
} from '../globals'
|
||||||
import {
|
import {
|
||||||
chsRegex,
|
chsRegex,
|
||||||
|
chsSegmenter,
|
||||||
indexingStep,
|
indexingStep,
|
||||||
IndexingStepType,
|
IndexingStepType,
|
||||||
SPACE_OR_PUNCTUATION,
|
SPACE_OR_PUNCTUATION,
|
||||||
@@ -24,7 +25,6 @@ import { cacheManager } from '../cache-manager'
|
|||||||
|
|
||||||
const tokenize = (text: string): string[] => {
|
const tokenize = (text: string): string[] => {
|
||||||
const tokens = text.split(SPACE_OR_PUNCTUATION)
|
const tokens = text.split(SPACE_OR_PUNCTUATION)
|
||||||
const chsSegmenter = (app as any).plugins.plugins['cm-chs-patch']
|
|
||||||
|
|
||||||
if (chsSegmenter) {
|
if (chsSegmenter) {
|
||||||
return tokens.flatMap(word =>
|
return tokens.flatMap(word =>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
} from 'obsidian'
|
} from 'obsidian'
|
||||||
import type { SearchMatch } from '../globals'
|
import type { SearchMatch } from '../globals'
|
||||||
import {
|
import {
|
||||||
|
chsSegmenter,
|
||||||
excerptAfter,
|
excerptAfter,
|
||||||
excerptBefore,
|
excerptBefore,
|
||||||
highlightClass,
|
highlightClass,
|
||||||
@@ -70,7 +71,10 @@ export function getAllIndices(text: string, regex: RegExp): SearchMatch[] {
|
|||||||
*/
|
*/
|
||||||
export function stringsToRegex(strings: string[]): RegExp {
|
export function stringsToRegex(strings: string[]): RegExp {
|
||||||
if (!strings.length) return /^$/g
|
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')
|
const reg = new RegExp(`(${joined})`, 'gi')
|
||||||
// console.log(reg)
|
// console.log(reg)
|
||||||
return reg
|
return reg
|
||||||
|
|||||||
Reference in New Issue
Block a user