Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve exporting Markdown https://github.com/siyuan-note/siyuan/issues/13273

Danieleb21e8f90fc6
diff --git a/kernel/model/export.go b/kernel/model/export.go
index 2f998cfdb7..ad53b3dd7d 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -1966,8 +1966,17 @@ func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDest
anchorSpan := &ast.Node{Type: ast.NodeInlineHTML, Tokens: []byte("<span id=\"" + n.ID + "\"></span>")}
if ast.NodeDocument != n.Type {
firstLeaf := treenode.FirstLeafBlock(n)
- if nil != firstLeaf && nil != firstLeaf.FirstChild {
- firstLeaf.FirstChild.InsertBefore(anchorSpan)
+ if nil != firstLeaf {
+ if ast.NodeTable == firstLeaf.Type {
+ firstLeaf.InsertBefore(anchorSpan)
+ firstLeaf.InsertBefore(&ast.Node{Type: ast.NodeHardBreak})
+ } else {
+ if nil != firstLeaf.FirstChild {
+ firstLeaf.FirstChild.InsertBefore(anchorSpan)
+ } else {
+ firstLeaf.AppendChild(anchorSpan)
+ }
+ }
} else {
n.AppendChild(anchorSpan)
}