mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-14 19:18:06 +01:00
🎨 Improve pandoc export
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
cf392b04ae
commit
b59c6fda43
2 changed files with 21 additions and 20 deletions
|
|
@ -111,25 +111,6 @@ func InitPandoc() {
|
|||
return
|
||||
}
|
||||
|
||||
tempPandocDir := filepath.Join(TempDir, "pandoc")
|
||||
|
||||
if confPath := filepath.Join(ConfDir, "conf.json"); gulu.File.IsExist(confPath) {
|
||||
// Workspace built-in Pandoc is no longer initialized after customizing Pandoc path https://github.com/siyuan-note/siyuan/issues/8377
|
||||
if data, err := os.ReadFile(confPath); err == nil {
|
||||
conf := map[string]interface{}{}
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &conf); err == nil && nil != conf["export"] {
|
||||
export := conf["export"].(map[string]interface{})
|
||||
if customPandocBinPath := export["pandocBin"].(string); !strings.HasPrefix(customPandocBinPath, tempPandocDir) {
|
||||
if pandocVer := getPandocVer(customPandocBinPath); "" != pandocVer {
|
||||
PandocBinPath = customPandocBinPath
|
||||
logging.LogInfof("custom pandoc [ver=%s, bin=%s]", pandocVer, PandocBinPath)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PandocTemplatePath = filepath.Join(WorkingDir, "pandoc-resources", "pandoc-template.docx")
|
||||
if !gulu.File.IsExist(PandocTemplatePath) {
|
||||
PandocTemplatePath = filepath.Join(WorkingDir, "pandoc", "pandoc-resources", "pandoc-template.docx")
|
||||
|
|
@ -150,6 +131,25 @@ func InitPandoc() {
|
|||
|
||||
defer eventbus.Publish(EvtConfPandocInitialized)
|
||||
|
||||
tempPandocDir := filepath.Join(TempDir, "pandoc")
|
||||
|
||||
if confPath := filepath.Join(ConfDir, "conf.json"); gulu.File.IsExist(confPath) {
|
||||
// Workspace built-in Pandoc is no longer initialized after customizing Pandoc path https://github.com/siyuan-note/siyuan/issues/8377
|
||||
if data, err := os.ReadFile(confPath); err == nil {
|
||||
conf := map[string]interface{}{}
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &conf); err == nil && nil != conf["export"] {
|
||||
export := conf["export"].(map[string]interface{})
|
||||
if customPandocBinPath := export["pandocBin"].(string); !strings.HasPrefix(customPandocBinPath, tempPandocDir) {
|
||||
if pandocVer := getPandocVer(customPandocBinPath); "" != pandocVer {
|
||||
PandocBinPath = customPandocBinPath
|
||||
logging.LogInfof("custom pandoc [ver=%s, bin=%s]", pandocVer, PandocBinPath)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if gulu.OS.IsWindows() {
|
||||
if "amd64" == runtime.GOARCH {
|
||||
PandocBinPath = filepath.Join(tempPandocDir, "bin", "pandoc.exe")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue