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: Search preview supports HTML tags in inline code content https://github.com/siyuan-note/siyuan/issues/11418
Daniel4624b62e4d4b
diff --git a/kernel/model/search.go b/kernel/model/search.goindex aaf19de66f..ff260314aa 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -35,6 +35,7 @@ import ("github.com/88250/gulu""github.com/88250/lute""github.com/88250/lute/ast"+ "github.com/88250/lute/html""github.com/88250/lute/lex""github.com/88250/lute/parse""github.com/88250/vitess-sqlparser/sqlparser"@@ -1538,8 +1539,8 @@ func stringQuery(query string) string {// markReplaceSpan 用于处理搜索高亮。func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markSpanDataType string, luteEngine *lute.Lute) bool {- text := n.Content()if ast.NodeText == n.Type {+ text := n.Content()escapedText := util.EscapeHTML(text)escapedKeywords := make([]string, len(keywords))for i, keyword := range keywords {@@ -1569,6 +1570,17 @@ func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markSreturn false}+ var text string+ if n.IsTextMarkType("code") {+ // code 在前面的 n.+ for i, k := range keywords {+ keywords[i] = html.EscapeString(k)+ }+ text = n.TextMarkTextContent+ } else {+ text = n.Content()+ }+startTag := search.GetMarkSpanStart(markSpanDataType)text = search.EncloseHighlighting(text, keywords, startTag, search.GetMarkSpanEnd(), Conf.Search.CaseSensitive, false)if strings.Contains(text, search.MarkDataType) {diff --git a/kernel/search/mark.go b/kernel/search/mark.goindex f40196a2a8..d8fecb2257 100644--- a/kernel/search/mark.go+++ b/kernel/search/mark.go@@ -114,7 +114,7 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark strret = textif reg, err := regexp.Compile(re); nil == err {- ret = reg.ReplaceAllStringFunc(text, func(s string) string { return openMark + util.EscapeHTML(s) + closeMark })+ ret = reg.ReplaceAllStringFunc(text, func(s string) string { return openMark + s + closeMark })}// 搜索结果预览包含转义符问题 Search results preview contains escape character issue https://github.com/siyuan-note/siyuan/issues/9790