Skip to content

Commit

Permalink
🎨 Use slash instead of backslash on windows #153 (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokeyish authored Feb 2, 2024
1 parent 05f5859 commit 6d061d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 进行安装。

Expand Down
22 changes: 21 additions & 1 deletion src/exporto0o.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<keyof Variables> = [
'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'
Expand Down
3 changes: 1 addition & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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.
);
Expand Down

0 comments on commit 6d061d4

Please sign in to comment.