From 78f260147148756a23b66e395a7b475840bd48da Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 28 May 2023 11:54:48 +0800 Subject: [PATCH] :art: Workspace built-in Pandoc is no longer initialized after customizing Pandoc path https://github.com/siyuan-note/siyuan/issues/8377 --- kernel/util/pandoc.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel/util/pandoc.go b/kernel/util/pandoc.go index c3a13a0cf..96cf43326 100644 --- a/kernel/util/pandoc.go +++ b/kernel/util/pandoc.go @@ -87,6 +87,24 @@ func initPandoc() { } pandocDir := 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); nil == err { + conf := map[string]interface{}{} + if err = gulu.JSON.UnmarshalJSON(data, &conf); nil == err && nil != conf["export"] { + export := conf["export"].(map[string]interface{}) + if customPandocBinPath := export["pandocBin"].(string); !strings.HasPrefix(customPandocBinPath, pandocDir) { + if pandocVer := getPandocVer(customPandocBinPath); "" != pandocVer { + PandocBinPath = customPandocBinPath + logging.LogInfof("custom pandoc [ver=%s, bin=%s]", pandocVer, PandocBinPath) + return + } + } + } + } + } + if gulu.OS.IsWindows() { PandocBinPath = filepath.Join(pandocDir, "bin", "pandoc.exe") } else if gulu.OS.IsDarwin() || gulu.OS.IsLinux() {