Fix: issue#190 (#317)

* Fixed search results with diacritics

- Caches are now stored with diacritics regardless of settings.ignoreDiacritics
- Modified getMatches() behavior to return results with correct form
- Modified ResultItemVault.svelte

* Fixed highlighting words with comma and period

- remove commas and periods from matches

* Fixed highlighting of Cyrillic characters

- changed highlight regexp determination to be based on character type

* Fixed highlighting problem of Japanese and Korean

- marked some Japanese diacritics to escape removal
- added NFC normalization to keep right form of Korean character

* Fixed highlighting of words with punctuation

- deleted space/punctuation list from stringsToRegex()
- it seems to be working correctly with words with punctuation and hyphenated words AFAIK

* Deleted some unused imports

* Modified the comment

* Added comment

* Fixed highlighting issue with comma and period

* Fixed highlighting issue with caret and other symbols

- Added `^` to separators
- Changed regex to use separators
- Added escape of `^` from diacritics removal
This commit is contained in:
Hajime Nagisa
2023-11-29 15:32:25 +09:00
committed by GitHub
parent 115886af78
commit 9cac7c0581
5 changed files with 44 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import { settings, showExcerpt } from 'src/settings'
import { showExcerpt } from 'src/settings'
import type { ResultNote } from '../globals'
import {
getExtension,
@@ -7,12 +7,16 @@
isFileImage,
isFilePDF,
pathWithoutFilename,
removeDiacritics,
} from '../tools/utils'
import ResultItemContainer from './ResultItemContainer.svelte'
import { TFile, setIcon, App } from 'obsidian'
import { cloneDeep } from 'lodash-es'
import { stringsToRegex, getMatches, makeExcerpt, highlightText } from 'src/tools/text-processing'
import {
stringsToRegex,
getMatches,
makeExcerpt,
highlightText,
} from 'src/tools/text-processing'
export let selected = false
export let note: ResultNote
@@ -44,9 +48,6 @@
$: {
title = note.basename
notePath = pathWithoutFilename(note.path)
if (settings.ignoreDiacritics) {
title = removeDiacritics(title)
}
// Icons
if (elFolderPathIcon) {