mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 06:30:15 +08:00
WORKAROUND: Add for environment variable for pandoc
This commit is contained in:
parent
c6708e9d9a
commit
cc2e9d13c0
@ -5,6 +5,7 @@
|
|||||||
| `MARKTEXT_DEBUG` | Enable debug mode. |
|
| `MARKTEXT_DEBUG` | Enable debug mode. |
|
||||||
| `MARKTEXT_DEBUG_KEYBOARD` | Print more keyboard information when debug mode is enabled. |
|
| `MARKTEXT_DEBUG_KEYBOARD` | Print more keyboard information when debug mode is enabled. |
|
||||||
| `MARKTEXT_ERROR_INTERACTION` | Never show the error dialog to report bugs. |
|
| `MARKTEXT_ERROR_INTERACTION` | Never show the error dialog to report bugs. |
|
||||||
|
| `MARKTEXT_PANDOC` | Overwrite the pandoc path. |
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
// Copy from https://github.com/utatti/simple-pandoc/blob/master/index.js
|
// Copy from https://github.com/utatti/simple-pandoc/blob/master/index.js
|
||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import commandExists from 'command-exists'
|
import commandExists from 'command-exists'
|
||||||
|
import { isFile } from 'common/filesystem'
|
||||||
|
|
||||||
const command = 'pandoc'
|
const pandocCommand = 'pandoc'
|
||||||
|
|
||||||
|
const getCommand = () => {
|
||||||
|
if (envPathExists()) {
|
||||||
|
return process.env.MARKTEXT_PANDOC
|
||||||
|
}
|
||||||
|
return pandocCommand
|
||||||
|
}
|
||||||
|
|
||||||
const pandoc = (from, to, ...args) => {
|
const pandoc = (from, to, ...args) => {
|
||||||
|
const command = getCommand()
|
||||||
const option = ['-s', from, '-t', to].concat(args)
|
const option = ['-s', from, '-t', to].concat(args)
|
||||||
|
|
||||||
const converter = () => new Promise((resolve, reject) => {
|
const converter = () => new Promise((resolve, reject) => {
|
||||||
@ -29,7 +38,14 @@ const pandoc = (from, to, ...args) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pandoc.exists = () => {
|
pandoc.exists = () => {
|
||||||
return commandExists.sync(command)
|
if (envPathExists()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return commandExists.sync(pandocCommand)
|
||||||
|
}
|
||||||
|
|
||||||
|
const envPathExists = () => {
|
||||||
|
return !!process.env.MARKTEXT_PANDOC && isFile(process.env.MARKTEXT_PANDOC)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default pandoc
|
export default pandoc
|
||||||
|
Loading…
Reference in New Issue
Block a user