This commit is contained in:
Daniel 2024-12-09 17:31:42 +08:00
parent 5a44e10bdd
commit 8d0aac690e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 6 additions and 2 deletions

View file

@ -1990,7 +1990,7 @@ func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDest
if 4 == blockRefMode { // 脚注+锚点哈希
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 {
firstLeaf := treenode.FirstLeafBlock(n)
if nil != firstLeaf {
@ -2226,7 +2226,7 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
}
} else {
if 4 == blockRefMode { // 脚注+锚点哈希
anchorSpan := &ast.Node{Type: ast.NodeInlineHTML, Tokens: []byte("<span id=\"" + id + "\"></span>")}
anchorSpan := treenode.NewSpanAnchor(id)
ret.Root.PrependChild(anchorSpan)
}
}

View file

@ -116,3 +116,7 @@ func NewParagraph(id string) (ret *ast.Node) {
ret.SetIALAttr("updated", newID[:14])
return
}
func NewSpanAnchor(id string) (ret *ast.Node) {
return &ast.Node{Type: ast.NodeInlineHTML, Tokens: []byte("<span id=\"" + id + "\" style=\"display: none;\"></span>")}
}