mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 Support for embedding images when exporting EPUB, ODT and RTF Fix https://github.com/siyuan-note/siyuan/issues/8288
This commit is contained in:
parent
de2a414968
commit
9aca165875
2 changed files with 16 additions and 15 deletions
|
|
@ -1032,7 +1032,7 @@ func BatchExportMarkdown(boxID, folderPath string) (zipPath string) {
|
||||||
for _, docFile := range docFiles {
|
for _, docFile := range docFiles {
|
||||||
docPaths = append(docPaths, docFile.path)
|
docPaths = append(docPaths, docFile.path)
|
||||||
}
|
}
|
||||||
zipPath = exportPandocConvertZip(boxID, baseFolderName, docPaths, "", "md", ".md")
|
zipPath = exportPandocConvertZip(boxID, baseFolderName, docPaths, "", "", ".md")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2030,20 +2030,6 @@ func exportPandocConvertZip(boxID, baseFolderName string, docPaths []string,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用 Pandoc 进行格式转换
|
|
||||||
output, err := util.Pandoc(pandocFrom, pandocTo, writePath, md)
|
|
||||||
if nil != err {
|
|
||||||
logging.LogErrorf("pandoc failed: %s", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if "odt" != pandocTo && "epub" != pandocTo && "rtf" != pandocTo {
|
|
||||||
if err := gulu.File.WriteFileSafer(writePath, gulu.Str.ToBytes(output), 0644); nil != err {
|
|
||||||
logging.LogErrorf("write export markdown file [%s] failed: %s", writePath, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析导出后的标准 Markdown,汇总 assets
|
// 解析导出后的标准 Markdown,汇总 assets
|
||||||
tree := parse.Parse("", gulu.Str.ToBytes(md), luteEngine.ParseOptions)
|
tree := parse.Parse("", gulu.Str.ToBytes(md), luteEngine.ParseOptions)
|
||||||
var assets []string
|
var assets []string
|
||||||
|
|
@ -2067,6 +2053,20 @@ func exportPandocConvertZip(boxID, baseFolderName string, docPaths []string,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 调用 Pandoc 进行格式转换
|
||||||
|
output, err := util.Pandoc(pandocFrom, pandocTo, writePath, md)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("pandoc failed: %s", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if "odt" != pandocTo && "epub" != pandocTo && "rtf" != pandocTo {
|
||||||
|
if err := gulu.File.WriteFileSafer(writePath, gulu.Str.ToBytes(output), 0644); nil != err {
|
||||||
|
logging.LogErrorf("write export markdown file [%s] failed: %s", writePath, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zipPath = exportFolder + ".zip"
|
zipPath = exportFolder + ".zip"
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ func Pandoc(from, to, o, content string) (ret string, err error) {
|
||||||
args := []string{
|
args := []string{
|
||||||
"--from", from,
|
"--from", from,
|
||||||
"--to", to,
|
"--to", to,
|
||||||
|
"--resource-path", filepath.Dir(o),
|
||||||
"-s",
|
"-s",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue