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: Supports replacing tags with other inline elements https://github.com/siyuan-note/siyuan/issues/11238
Daniel87709cd5a192
diff --git a/kernel/model/search.go b/kernel/model/search.goindex 6da54f8004..13492699e2 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -728,7 +728,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "em")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "em", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)mergeSamePreNext(n)@@ -738,7 +738,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "strong")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "strong", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)mergeSamePreNext(n)@@ -748,7 +748,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "kbd")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "kbd", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)}@@ -757,7 +757,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "mark")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "mark", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)mergeSamePreNext(n)@@ -767,7 +767,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "s")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "s", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)mergeSamePreNext(n)@@ -777,7 +777,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "sub")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "sub", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)}@@ -786,7 +786,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "sup")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "sup", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)}@@ -795,7 +795,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "tag")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "tag", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)}@@ -804,7 +804,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "u")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "u", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)mergeSamePreNext(n)@@ -853,7 +853,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn ast.WalkContinue}- replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "text")+ replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "text", luteEngine)if "" == n.TextMarkTextContent {unlinks = append(unlinks, n)mergeSamePreNext(n)@@ -935,7 +935,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, idsreturn}-func replaceNodeTextMarkTextContent(n *ast.Node, method int, keyword, escapedKey string, replacement string, r *regexp.Regexp, typ string) {+func replaceNodeTextMarkTextContent(n *ast.Node, method int, keyword, escapedKey string, replacement string, r *regexp.Regexp, typ string, luteEngine *lute.Lute) {if 0 == method {if strings.Contains(typ, "tag") {keyword = strings.TrimPrefix(keyword, "#")@@ -955,7 +955,21 @@ func replaceNodeTextMarkTextContent(n *ast.Node, method int, keyword, escapedKey} else if strings.Contains(content, keyword) {content = strings.ReplaceAll(content, keyword, replacement)}- n.InsertBefore(&ast.Node{Type: ast.NodeText, Tokens: []byte(content)})++ tree := parse.Inline("", []byte(content), luteEngine.ParseOptions)+ if nil == tree.Root.FirstChild {+ return+ }+ parse.NestedInlines2FlattedSpans(tree, false)++ var replaceNodes []*ast.Node+ for rNode := tree.Root.FirstChild.FirstChild; nil != rNode; rNode = rNode.Next {+ replaceNodes = append(replaceNodes, rNode)+ }++ for _, rNode := range replaceNodes {+ n.InsertBefore(rNode)+ }n.TextMarkTextContent = ""return}