mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🎨 Improve exporting block ref https://github.com/siyuan-note/siyuan/issues/13331
This commit is contained in:
parent
5a44e10bdd
commit
8d0aac690e
2 changed files with 6 additions and 2 deletions
|
|
@ -1990,7 +1990,7 @@ func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDest
|
||||||
if 4 == blockRefMode { // 脚注+锚点哈希
|
if 4 == blockRefMode { // 脚注+锚点哈希
|
||||||
if n.IsBlock() && gulu.Str.Contains(n.ID, defBlockIDs) {
|
if n.IsBlock() && gulu.Str.Contains(n.ID, defBlockIDs) {
|
||||||
// 如果是定义块,则在开头处添加锚点
|
// 如果是定义块,则在开头处添加锚点
|
||||||
anchorSpan := &ast.Node{Type: ast.NodeInlineHTML, Tokens: []byte("<span id=\"" + n.ID + "\"></span>")}
|
anchorSpan := treenode.NewSpanAnchor(n.ID)
|
||||||
if ast.NodeDocument != n.Type {
|
if ast.NodeDocument != n.Type {
|
||||||
firstLeaf := treenode.FirstLeafBlock(n)
|
firstLeaf := treenode.FirstLeafBlock(n)
|
||||||
if nil != firstLeaf {
|
if nil != firstLeaf {
|
||||||
|
|
@ -2226,7 +2226,7 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if 4 == blockRefMode { // 脚注+锚点哈希
|
if 4 == blockRefMode { // 脚注+锚点哈希
|
||||||
anchorSpan := &ast.Node{Type: ast.NodeInlineHTML, Tokens: []byte("<span id=\"" + id + "\"></span>")}
|
anchorSpan := treenode.NewSpanAnchor(id)
|
||||||
ret.Root.PrependChild(anchorSpan)
|
ret.Root.PrependChild(anchorSpan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,3 +116,7 @@ func NewParagraph(id string) (ret *ast.Node) {
|
||||||
ret.SetIALAttr("updated", newID[:14])
|
ret.SetIALAttr("updated", newID[:14])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewSpanAnchor(id string) (ret *ast.Node) {
|
||||||
|
return &ast.Node{Type: ast.NodeInlineHTML, Tokens: []byte("<span id=\"" + id + "\" style=\"display: none;\"></span>")}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue