diff --git a/README.md b/README.md index 3dbbfae..99e6124 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Where `Markdown`,`Markdown (Hugo)`,`HTML` will export and its media resource tog ## Installation -1. First install the latest `pandoc` (2.19+), and then add `pandoc` path to environment variable `PATH` or set absolute path of `pandoc` in the plugin setting view. +1. First install the latest `pandoc` (3.1.9+), and then add `pandoc` path to environment variable `PATH` or set absolute path of `pandoc` in the plugin setting view. See more details in [https://pandoc.org/installing.html](https://pandoc.org/installing.html)。 diff --git a/README_zh-CN.md b/README_zh-CN.md index 4be413a..693a72f 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -16,7 +16,7 @@ ![](https://raw.githubusercontent.com/mokeyish/obsidian-enhancing-export/master/screenshot/settingview_zh-CN.png) ## 安装 -1. 需要先安装最新的 `pandoc`(2.18+),最好配置到 PATH 环境变量,或者设置界面指定路径。 +1. 需要先安装最新的 `pandoc`(3.1.9+),最好配置到 PATH 环境变量,或者设置界面指定路径。 参考地址:[https://pandoc.org/installing.html](https://pandoc.org/installing.html) 2. 在 Obsidian 插件市场,搜索 `obsidian-enhancing-export` 进行安装。 diff --git a/src/exporto0o.ts b/src/exporto0o.ts index 912ecd1..90f62d4 100644 --- a/src/exporto0o.ts +++ b/src/exporto0o.ts @@ -1,5 +1,6 @@ import * as ct from 'electron'; import * as fs from 'fs'; +import process from 'process'; import path from 'path'; import argsParser from 'yargs-parser'; import { Variables, ExportSetting, extractDefaultExtension as extractExtension, createEnv } from './settings'; @@ -150,7 +151,26 @@ export async function exportToOo( // process Environment variables.. const env = (variables.env = createEnv(getPlatformValue(globalSetting.env) ?? {}, variables)); - const pandocPath = pandoc.normalizePath(getPlatformValue(globalSetting.pandocPath)); + let pandocPath = pandoc.normalizePath(getPlatformValue(globalSetting.pandocPath)); + + if (process.platform === 'win32') { + pandocPath = pandocPath.replaceAll('\\', '/'); + const pathKeys: Array = [ + 'pluginDir', + 'luaDir', + 'outputDir', + 'outputPath', + 'currentDir', + 'currentPath', + 'attachmentFolderPath', + 'vaultDir', + ]; + + for (const pathKey of pathKeys) { + const path = variables[pathKey] as string; + variables[pathKey] = path.replaceAll('\\', '/'); + } + } const cmdTpl = setting.type === 'pandoc' diff --git a/src/settings.ts b/src/settings.ts index 580486c..72e86c2 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,4 +1,3 @@ -import * as os from 'os'; import export_templates from './export_templates'; import { setPlatformValue, PlatformValue, renderTemplate, getPlatformValue } from './utils'; import type { PropertyGridMeta } from './ui/components/PropertyGrid'; @@ -118,7 +117,7 @@ export const DEFAULT_ENV = (() => { env, { 'TEXINPUTS': '${pluginDir}/textemplate/;', // Windows uses ; rather than : for appending - 'PATH': `${os.homedir()}AppData\\Local\\Pandoc\\:\${PATH}`, + 'PATH': '${HOME}\\AppData\\Local\\Pandoc;${PATH}', }, 'win32' // available for windows only. );