mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-27 20:08:49 +01:00
🎨 When exporting Markdown, <br /> nodes in non-tables are replaced with \n text nodes https://github.com/siyuan-note/siyuan/issues/9509
This commit is contained in:
parent
e32c8f8c1c
commit
b95980f4b5
1 changed files with 19 additions and 0 deletions
|
|
@ -1525,6 +1525,25 @@ func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDest
|
|||
})
|
||||
}
|
||||
|
||||
// When exporting Markdown, `<br />` nodes in non-tables are replaced with `\n` text nodes https://github.com/siyuan-note/siyuan/issues/9509
|
||||
var unlinks []*ast.Node
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if ast.NodeBr == n.Type {
|
||||
if !n.ParentIs(ast.NodeTableCell) {
|
||||
n.InsertBefore(&ast.Node{Type: ast.NodeText, Tokens: []byte("\n")})
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
for _, unlink := range unlinks {
|
||||
unlink.Unlink()
|
||||
}
|
||||
|
||||
renderer := render.NewProtyleExportMdRenderer(tree, luteEngine.RenderOptions)
|
||||
ret = gulu.Str.FromBytes(renderer.Render())
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue