Moved a var

This commit is contained in:
Simon Cambier
2022-05-04 20:34:56 +02:00
parent 7fcac79b77
commit b7242fbee4
2 changed files with 3 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ export const regexWikilink = /^!?\[\[(?<name>.+?)(\|(?<alias>.+?))?\]\]/
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 excerptBefore = 100
export const excerptAfter = 180

View File

@@ -1,6 +1,7 @@
import { Notice, TFile, type TAbstractFile } from 'obsidian'
import MiniSearch, { type SearchResult } from 'minisearch'
import {
chsRegex,
SPACE_OR_PUNCTUATION,
type IndexedNote,
type ResultNote,
@@ -17,15 +18,13 @@ import type { Query } from './query'
let minisearchInstance: MiniSearch<IndexedNote>
let indexedNotes: Record<string, IndexedNote> = {}
const chsPattern = /[\u4e00-\u9fa5]/
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 =>
chsPattern.test(word) ? chsSegmenter.cut(word) : [word],
chsRegex.test(word) ? chsSegmenter.cut(word) : [word],
)
}
else return tokens