feat: support custom pandoc reference document

This commit is contained in:
purocean
2022-01-20 21:01:11 +08:00
parent 4c227830eb
commit 967d95e21a
6 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ The application generated data is stored in `<home>/yank-note` dir, click the "O
Directory description
1. configuration file `<home>/yank-note/config.json`
1. recycle bin `<home>/yank-note/trash`
1. export docx reference doc `<home>/yank-note/pandoc-reference.docx`
1. plug-ins `<home>/yank-note/plugins`
1. themes `<home>/yank-note/themes`
+1 -1
View File
@@ -20,7 +20,7 @@ define:
目录说明:
1. 配置文件 `<home>/yank-note/config.json`
1. 回收站 `<home>/yank-note/trash`
1. 导出 docx 参考文档 `<home>/yank-note/pandoc-reference.docx`
1. 插件 `<home>/yank-note/plugins`
1. 主题 `<home>/yank-note/themes`
+2
View File
@@ -22,6 +22,8 @@ export const RESOURCES_DIR = convertAppPath(path.join(__dirname, 'resources'))
export const BUILD_IN_STYLES = ['github.css']
export const PANDOC_REFERENCE_FILE = 'pandoc-reference.docx'
export const GITHUB_URL = 'https://github.com/purocean/yn'
export const FLAG_DISABLE_SERVER = false
+2 -2
View File
@@ -2,10 +2,10 @@ import * as os from 'os'
import * as fs from 'fs-extra'
import * as path from 'path'
import { spawn } from 'child_process'
import { BIN_DIR, RESOURCES_DIR } from '../constant'
import { BIN_DIR, PANDOC_REFERENCE_FILE, RESOURCES_DIR, USER_DIR } from '../constant'
const binPath = path.join(BIN_DIR, os.platform() + '-pandoc-2.7.3' + (os.platform() === 'win32' ? '.exe' : ''))
const docxTplPath = path.join(RESOURCES_DIR, './tpl.docx')
const docxTplPath = path.join(USER_DIR, PANDOC_REFERENCE_FILE)
const filterPath = path.join(RESOURCES_DIR, './pandoc-filter.lua')
const convert = async (source: string, fromType: string, toType: string, resourcePath: string) => {
+7 -1
View File
@@ -1,6 +1,6 @@
import * as fs from 'fs-extra'
import * as path from 'path'
import { USER_DIR, USER_PLUGIN_DIR, USER_THEME_DIR, RESOURCES_DIR, BUILD_IN_STYLES } from './constant'
import { USER_DIR, USER_PLUGIN_DIR, USER_THEME_DIR, RESOURCES_DIR, BUILD_IN_STYLES, PANDOC_REFERENCE_FILE } from './constant'
import './updater'
export default function () {
@@ -29,4 +29,10 @@ window.registerPlugin({
fs.readFileSync(path.join(RESOURCES_DIR, style))
)
})
const docxTplPath = path.join(USER_DIR, PANDOC_REFERENCE_FILE)
if (!fs.existsSync(docxTplPath)) {
fs.createReadStream(path.join(RESOURCES_DIR, PANDOC_REFERENCE_FILE))
.pipe(fs.createWriteStream(docxTplPath))
}
}