mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
1d10e8d5b8
1 changed files with 13 additions and 4 deletions
|
|
@ -2109,6 +2109,7 @@ func exportMarkdownContent0(id string, tree *parse.Tree, cloudAssetsBase string,
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDocDir := path.Dir(tree.HPath)
|
currentDocDir := path.Dir(tree.HPath)
|
||||||
|
currentDocDir = util.FilterFilePath(currentDocDir)
|
||||||
|
|
||||||
var unlinks []*ast.Node
|
var unlinks []*ast.Node
|
||||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
|
|
@ -2162,11 +2163,19 @@ func exportMarkdownContent0(id string, tree *parse.Tree, cloudAssetsBase string,
|
||||||
href = "#" + defID
|
href = "#" + defID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newHref := strings.TrimPrefix(href, currentDocDir)
|
|
||||||
if !strings.HasPrefix(newHref, ".md") {
|
sameDir := path.Dir(href) == currentDocDir
|
||||||
href = newHref
|
|
||||||
}
|
|
||||||
href = util.FilterFilePath(href)
|
href = util.FilterFilePath(href)
|
||||||
|
if !sameDir {
|
||||||
|
var relErr error
|
||||||
|
href, relErr = filepath.Rel(currentDocDir, href)
|
||||||
|
if nil != relErr {
|
||||||
|
logging.LogWarnf("get relative path from [%s] to [%s] failed: %s", currentDocDir, href, relErr)
|
||||||
|
}
|
||||||
|
href = filepath.ToSlash(href)
|
||||||
|
} else {
|
||||||
|
href = strings.TrimPrefix(href, currentDocDir+"/")
|
||||||
|
}
|
||||||
blockRefLink := &ast.Node{Type: ast.NodeTextMark, TextMarkType: "a", TextMarkTextContent: linkText, TextMarkAHref: href}
|
blockRefLink := &ast.Node{Type: ast.NodeTextMark, TextMarkType: "a", TextMarkTextContent: linkText, TextMarkAHref: href}
|
||||||
blockRefLink.KramdownIAL = n.KramdownIAL
|
blockRefLink.KramdownIAL = n.KramdownIAL
|
||||||
n.InsertBefore(blockRefLink)
|
n.InsertBefore(blockRefLink)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue