An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 简化搜索命中结果高亮实现
Liang Dingf6afd1c142e2
diff --git a/kernel/search/mark.go b/kernel/search/mark.goindex e858f3fa5c..92b209a1e9 100644--- a/kernel/search/mark.go+++ b/kernel/search/mark.go@@ -78,7 +78,7 @@ func SplitKeyword(keyword string) (keywords []string) {return}-func EncloseHighlighting(text string, keywords []string, openMark, closeMark string, caseSensitive bool) string {+func EncloseHighlighting(text string, keywords []string, openMark, closeMark string, caseSensitive bool) (ret string) {ic := "(?i)"if caseSensitive {ic = "(?)"@@ -92,26 +92,10 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str}}re += ")"+ ret = text+if reg, err := regexp.Compile(re); nil == err {- text = reg.ReplaceAllStringFunc(text, func(s string) string {- return openMark + s + closeMark- })- } else {- for _, k := range keywords {- k = regexp.QuoteMeta(k)- var repls, words []string- if re, err := regexp.Compile(ic + k); nil == err {- words = re.FindAllString(text, -1)- } else {- re, _ := regexp.Compile(ic + regexp.QuoteMeta(k))- words = re.FindAllString(text, -1)- }- for _, word := range words {- repls = append(repls, word, openMark+word+closeMark)- }- replacer := strings.NewReplacer(repls...)- text = replacer.Replace(text)- }+ ret = reg.ReplaceAllStringFunc(text, func(s string) string { return openMark + s + closeMark })}- return text+ return}