This commit is contained in:
Daniel 2024-11-26 10:53:44 +08:00
parent da1b97f70c
commit 575869c546
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1944,6 +1944,8 @@ func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDest
})
}
currentDocDir := path.Dir(tree.HPath)
var unlinks []*ast.Node
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
@ -1979,12 +1981,14 @@ func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDest
var href string
bt := treenode.GetBlockTree(defID)
if nil != bt {
href += strings.TrimPrefix(bt.HPath, "/") + ".md"
href += bt.HPath + ".md"
if "d" != bt.Type {
href += "#" + defID
}
}
href = strings.TrimPrefix(href, currentDocDir)
href = util.FilterFilePath(href)
href = strings.TrimPrefix(href, "/")
blockRefLink := &ast.Node{Type: ast.NodeTextMark, TextMarkType: "a", TextMarkTextContent: linkText, TextMarkAHref: href}
blockRefLink.KramdownIAL = n.KramdownIAL
n.InsertBefore(blockRefLink)