Skip to content

Commit

Permalink
🎨 Improve exporting Markdown #13273
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Nov 27, 2024
1 parent f716e16 commit eb21e8f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions kernel/model/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit eb21e8f

Please sign in to comment.