🎨 改进提及和虚拟引用搜索分词 Fix https://github.com/siyuan-note/siyuan/issues/6176

This commit is contained in:
Liang Ding 2022-10-13 12:00:29 +08:00
parent 94f5ede090
commit 0b7c6a851e
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 13 additions and 2 deletions

View file

@ -791,10 +791,15 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
text := textBuf.String()
text = strings.ToLower(text)
text = luteEngine.Space(text)
var contain bool
for _, mentionKeyword := range mentionKeywords {
parts := strings.Split(text, " ")
for _, part := range parts {
if "" == part {
continue
}
if gulu.Str.IsASCII(mentionKeyword) {
if part == mentionKeyword {
contain = true

View file

@ -649,8 +649,14 @@ func markReplaceSpan(text string, keywords []string, replacementStart, replaceme
for _, k := range keywords {
if gulu.Str.IsASCII(k) {
if part == k {
parts[i] = replacementStart + k + replacementEnd
if gulu.Str.IsASCII(part) {
if part == k {
parts[i] = replacementStart + k + replacementEnd
}
} else {
if strings.Contains(part, k) {
parts[i] = strings.ReplaceAll(part, k, replacementStart+k+replacementEnd)
}
}
} else {
if strings.Contains(part, k) {