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: Convert HTML tags to text marks in CreateDocByMd https://github.com/siyuan-note/siyuan/issues/18997
Danielad4eda6d7a0c
diff --git a/kernel/model/file.go b/kernel/model/file.goindex d9cc3a8630..63e312cec9 100644--- a/kernel/model/file.go+++ b/kernel/model/file.go@@ -1369,6 +1369,7 @@ func CreateDocByMd(boxID, p, title, md string, sorts []string, arg map[string]an}luteEngine := util.NewLute()+ luteEngine.SetHTMLTag2TextMark(true)dom := luteEngine.Md2BlockDOM(md, false)tree, err = createDoc(box.ID, p, title, dom, false)if err != nil {diff --git a/kernel/model/file_test.go b/kernel/model/file_test.goindex ff767beb6f..d1bf2f1566 100644--- a/kernel/model/file_test.go+++ b/kernel/model/file_test.go@@ -24,6 +24,7 @@ import ("strings""testing"+ "github.com/88250/lute/ast""github.com/88250/lute/parse""github.com/siyuan-note/siyuan/kernel/cache""github.com/siyuan-note/siyuan/kernel/conf"@@ -377,6 +378,38 @@ func TestValidateCreateDocDoesNotWrite(t *testing.T) {}}+func TestCreateDocByMdConvertsHTMLTagsToTextMarks(t *testing.T) {+ fixture := setupFileOperationTest(t)+ docID := "20260718000003-abcdefg"+ docPath := "/" + docID + ".sy"+ tree, err := CreateDocByMd(fixture.box.ID, docPath, "HTML text marks", "<kbd>Ctrl</kbd> <u>text</u>", nil, nil)+ if nil != err {+ t.Fatalf("create document from Markdown failed: %v", err)+ }+ t.Cleanup(func() {+ cache.RemoveTreeData(tree.ID)+ cache.RemoveDocIAL(tree.Path)+ })++ foundKbd := false+ foundUnderline := false+ ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {+ if !entering || ast.NodeTextMark != node.Type {+ return ast.WalkContinue+ }+ if "kbd" == node.TextMarkType && strings.Contains(node.TextMarkTextContent, "Ctrl") {+ foundKbd = true+ }+ if "u" == node.TextMarkType && strings.Contains(node.TextMarkTextContent, "text") {+ foundUnderline = true+ }+ return ast.WalkContinue+ })+ if !foundKbd || !foundUnderline {+ t.Fatalf("HTML tags were not converted to text marks: kbd=%t, underline=%t", foundKbd, foundUnderline)+ }+}+func TestValidateCreateDocReportsClosedNotebook(t *testing.T) {fixture := setupFileOperationTest(t)boxConf := fixture.box.GetConf()