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: Omit table cell attributes when exporting Markdown https://github.com/siyuan-note/siyuan/issues/19963
Daniel6d593bad3be6
diff --git a/kernel/model/export.go b/kernel/model/export.goindex b83b924d5f..b6742411be 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -3138,6 +3138,7 @@ func exportMarkdownContent0(id string, tree *parse.Tree, cloudAssetsBase string,luteEngine := NewLute()luteEngine.SetFootnotes(true)luteEngine.SetKramdownIAL(false)+ luteEngine.RenderOptions.OmitTableCellIAL = trueluteEngine.SetExportNormalizeTaskListMarker(true)if "" != cloudAssetsBase {luteEngine.RenderOptions.LinkBase = cloudAssetsBasediff --git a/kernel/model/export_markdown_table_test.go b/kernel/model/export_markdown_table_test.gonew file mode 100644index 0000000000..f5528bfa2e--- /dev/null+++ b/kernel/model/export_markdown_table_test.go@@ -0,0 +1,60 @@+package model++import (+ "strings"+ "testing"++ "github.com/88250/lute/ast"+ "github.com/88250/lute/parse"+ "github.com/siyuan-note/siyuan/kernel/conf"+)++func TestExportMarkdownContentOmitsTableCellIAL(t *testing.T) {+ oldConf := Conf+ Conf = NewAppConf()+ Conf.Editor = conf.NewEditor()+ Conf.Export = conf.NewExport()+ t.Cleanup(func() { Conf = oldConf })+ luteEngine := NewLute()+ tree := parse.Parse("", []byte("| Left | Center | Right |\n| :--- | :---: | ---: |\n| **bold** | middle | end |\n"), luteEngine.ParseOptions)+ var cells []*ast.Node+ ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {+ if entering && n.Type == ast.NodeTableCell {+ n.SetIALAttr("style", "text-align: left;")+ cells = append(cells, n)+ }+ return ast.WalkContinue+ })+ if len(cells) != 6 {+ t.Fatalf("expected six cells, got %d", len(cells))+ }+ markdown := exportMarkdownContent0(tree.Root.ID, tree, "", false, false, false,+ ".md", 3, 1, 0, "#", "#", "", "", false, false, nil, nil, false, nil, nil)+ if strings.Contains(markdown, "{:") || strings.Contains(markdown, "text-align") {+ t.Fatalf("internal cell attributes leaked into Markdown: %s", markdown)+ }+ for _, content := range []string{"Left", "Center", "Right", "**bold**", "middle", "end"} {+ if !strings.Contains(markdown, content) {+ t.Fatalf("missing %q in Markdown: %s", content, markdown)+ }+ }+ parsed := parse.Parse("", []byte(markdown), luteEngine.ParseOptions)+ tables := 0+ ast.Walk(parsed.Root, func(n *ast.Node, entering bool) ast.WalkStatus {+ if entering && n.Type == ast.NodeTable {+ tables+++ if len(n.TableAligns) != 3 || n.TableAligns[0] != 1 || n.TableAligns[1] != 2 || n.TableAligns[2] != 3 {+ t.Fatalf("column alignment changed: %v", n.TableAligns)+ }+ }+ return ast.WalkContinue+ })+ if tables != 1 {+ t.Fatalf("expected one exported table, got %d", tables)+ }+ for _, cell := range cells {+ if cell.IALAttr("style") != "text-align: left;" {+ t.Fatal("export removed the source cell style")+ }+ }+}