Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: 导出 PDF/HTML 时丢失自定义表情 https://github.com/siyuan-note/siyuan/issues/5535

Liang Ding333375c815c3
diff --git a/kernel/go.mod b/kernel/go.mod
index e8ebdf291c..9986e9f05d 100644
--- a/kernel/go.mod
+++ b/kernel/go.mod
@@ -7,7 +7,7 @@ require (
github.com/88250/css v0.1.2
github.com/88250/flock v0.8.2
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583
- github.com/88250/lute v1.7.5-0.20220727143137-4554c97d2e0e
+ github.com/88250/lute v1.7.5-0.20220728154341-bb906394d19e
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1
github.com/88250/pdfcpu v0.3.13
github.com/88250/protyle v0.0.0-20220519012506-0a2c8dc24397
diff --git a/kernel/go.sum b/kernel/go.sum
index be327f7a40..b9fe4e4536 100644
--- a/kernel/go.sum
+++ b/kernel/go.sum
@@ -58,8 +58,8 @@ github.com/88250/gulu v1.2.0/go.mod h1:ZhEJ98UjR2y7j2toGj4/b+1rRELcZFQAPq/Yjyin2
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583 h1:FhA/zJemLrbOYJpdMIMBezO5rGigQSdPR1kv+aztHfA=
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
github.com/88250/lute v1.7.4-0.20220426011157-34c9bfa2e148/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
-github.com/88250/lute v1.7.5-0.20220727143137-4554c97d2e0e h1:RsAEtEMRUWE3PDBNIqNKp7UfUvlvFP1pSiWbDEYmxIo=
-github.com/88250/lute v1.7.5-0.20220727143137-4554c97d2e0e/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
+github.com/88250/lute v1.7.5-0.20220728154341-bb906394d19e h1:cfFgpeJOTch5bJvRn8H8ysE2zNBJNo3tZFP9GpUmQvM=
+github.com/88250/lute v1.7.5-0.20220728154341-bb906394d19e/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1 h1:9Cb+iN639vUI2OcIBc+4oGwml9/0J6bL6dWNb8Al+1s=
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1/go.mod h1:jH6MMPr8G7AMzaVmWHXZQiB1DKO3giWbcWZ7UoJ1teI=
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=
diff --git a/kernel/model/export.go b/kernel/model/export.go
index e56b152080..6be4a96b19 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -249,6 +249,14 @@ func ExportMarkdownHTML(id, savePath string, docx bool) (name, dom string) {
}
}
+ // 复制自定义表情图片
+ from := filepath.Join(util.DataDir, "emojis")
+ to := filepath.Join(savePath, "emojis")
+ if err := gulu.File.Copy(from, to); nil != err {
+ logging.LogErrorf("copy emojis from [%s] to [%s] failed: %s", from, savePath, err)
+ return
+ }
+
luteEngine := NewLute()
luteEngine.SetFootnotes(true)
md := treenode.FormatNode(tree.Root, luteEngine)
@@ -331,6 +339,14 @@ func ExportHTML(id, savePath string, pdf bool) (name, dom string) {
return
}
}
+
+ // 复制自定义表情图片
+ from := filepath.Join(util.DataDir, "emojis")
+ to := filepath.Join(savePath, "emojis")
+ if err := gulu.File.Copy(from, to); nil != err {
+ logging.LogErrorf("copy emojis from [%s] to [%s] failed: %s", from, savePath, err)
+ return
+ }
} else { // 导出 PDF 需要将资源文件路径改为 HTTP 伺服
luteEngine.RenderOptions.LinkBase = "http://127.0.0.1:" + util.ServerPort + "/"
}