Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833

Liang Dinged3fe917e525
diff --git a/kernel/search/mark.go b/kernel/search/mark.go
index b6c35a1222..6296439ee5 100644
--- a/kernel/search/mark.go
+++ b/kernel/search/mark.go
@@ -18,10 +18,12 @@ package search
import (
"fmt"
+ "github.com/88250/gulu"
"regexp"
"strings"
"unicode/utf8"
+ "github.com/88250/lute/lex"
"github.com/siyuan-note/siyuan/kernel/util"
)
@@ -86,8 +88,17 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
}
re := ic + "("
for i, k := range keywords {
+ wordBoundary := lex.IsASCIILetterNums(gulu.Str.ToBytes(k)) // Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833
k = regexp.QuoteMeta(k)
- re += "(" + k + ")"
+ re += "("
+ if wordBoundary {
+ re += "\\b"
+ }
+ re += k
+ if wordBoundary {
+ re += "\\b"
+ }
+ re += ")"
if i < len(keywords)-1 {
re += "|"
}