An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Preserve angled-bracket text in inline formatting https://github.com/siyuan-note/siyuan/issues/19614
Daniel6935648e211d
diff --git a/kernel/util/lute.go b/kernel/util/lute.goindex da02e59bed..141f6d60f2 100644--- a/kernel/util/lute.go+++ b/kernel/util/lute.go@@ -56,6 +56,8 @@ type Markdown struct {func NewLute() (ret *lute.Lute) {ret = lute.New()+ // 文本标记以 HTML 实体保存正文,解析时保留转义,避免渲染时将尖括号正文识别为标签。+ ret.ParseOptions.KeepEscaped = trueret.SetTextMark(true)ret.SetProtyleWYSIWYG(true)ret.SetBlockRef(true)diff --git a/kernel/util/lute_test.go b/kernel/util/lute_test.goindex fe8091e763..e6790bbe87 100644--- a/kernel/util/lute_test.go+++ b/kernel/util/lute_test.go@@ -17,6 +17,7 @@package utilimport (+ "strings""testing""github.com/88250/lute"@@ -24,6 +25,38 @@ import ("github.com/88250/lute/parse")+func TestLuteTextMarkEscapedContentRoundTrip(t *testing.T) {+ for _, blockType := range []string{"NodeHeading", "NodeParagraph"} {+ for _, mark := range []string{"em", "strong", "s", "mark", "sup", "sub", "em strong", "code"} {+ t.Run(blockType+"/"+mark, func(t *testing.T) {+ engine := NewLute()+ const content = "<vitae> & &lt;literal&gt;"+ dom := `<div data-node-id="20260918120000-abcdefg" data-type="` + blockType + `" data-subtype="h1"><div contenteditable="true">before <span data-type="` + mark + `">` + content + `</span> after</div></div>`+ for i := 0; i < 3; i++ {+ tree := engine.BlockDOM2Tree(dom)+ found := false+ ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {+ if entering && n.Type == ast.NodeTextMark {+ found = true+ if n.TextMarkTextContent != content {+ t.Fatalf("round %d: content = %q, want %q", i, n.TextMarkTextContent, content)+ }+ if rendered := engine.RenderNodeBlockDOM(n); !strings.Contains(rendered, content) {+ t.Fatalf("outline text lost: %s", rendered)+ }+ }+ return ast.WalkContinue+ })+ if !found {+ t.Fatal("text mark lost")+ }+ dom = engine.Tree2BlockDOM(tree, engine.RenderOptions, engine.ParseOptions)+ }+ })+ }+ }+}+func TestLuteFactoriesEnableCustomBlock(t *testing.T) {factories := []struct {name string