mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
🎨 Asset files no longer use HTTP server when exporting PDF https://github.com/siyuan-note/siyuan/issues/7965
This commit is contained in:
parent
7698add67e
commit
84244f4fc7
1 changed files with 4 additions and 14 deletions
|
|
@ -592,8 +592,6 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
|
|||
return
|
||||
}
|
||||
}
|
||||
} else if pdf && !image { // 导出 PDF 需要将资源文件路径改为 HTTP 伺服
|
||||
luteEngine.RenderOptions.LinkBase = "http://" + util.LocalHost + ":" + util.ServerPort + "/"
|
||||
}
|
||||
|
||||
if pdf {
|
||||
|
|
@ -685,23 +683,12 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) {
|
|||
}
|
||||
|
||||
var headings []*ast.Node
|
||||
var assetDests []string
|
||||
assetDests := assetsLinkDestsInTree(tree)
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if n.IsTextMarkType("a") {
|
||||
dest := n.TextMarkAHref
|
||||
if util.IsAssetLinkDest([]byte(dest)) {
|
||||
assetDests = append(assetDests, dest)
|
||||
}
|
||||
} else if ast.NodeLinkDest == n.Type {
|
||||
if util.IsAssetLinkDest(n.Tokens) {
|
||||
assetDests = append(assetDests, string(n.Tokens))
|
||||
}
|
||||
}
|
||||
|
||||
if ast.NodeHeading == n.Type && !n.ParentIs(ast.NodeBlockquote) {
|
||||
headings = append(headings, n)
|
||||
return ast.WalkSkipChildren
|
||||
|
|
@ -833,6 +820,9 @@ func processPDFLinkEmbedAssets(pdfCtx *pdfcpu.Context, assetDests []string, remo
|
|||
for _, link := range assetLinks {
|
||||
link.URI = strings.ReplaceAll(link.URI, "http://"+util.LocalHost+":"+util.ServerPort+"/export/temp/", "")
|
||||
link.URI, _ = url.PathUnescape(link.URI)
|
||||
if idx := strings.Index(link.URI, "?"); 0 < idx {
|
||||
link.URI = link.URI[:idx]
|
||||
}
|
||||
|
||||
if !removeAssets {
|
||||
// 不移除资源文件夹的话将超链接指向资源文件夹
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue