Skip to content

Commit

Permalink
✨ Allows to trigger export using shortcut keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mokeyish committed May 13, 2022
1 parent 96b145e commit 8858fa4
Show file tree
Hide file tree
Showing 22 changed files with 672 additions and 807 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
max_line_length = 140
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
"error",
"always"
]
}
},
"ignorePatterns": [
"dist/*"
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Where `Markdown`、`Markdown (Hugo)`、`Html` will export and its media resource

## Installation

1. First install `pandoc` , 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` (2.18+), 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 @@
![](screenshot/settingview_zh-CN.png)

## 安装
1. 需要先安装 `pandoc`,最好配置到 PATH 环境变量,或者设置界面指定路径。
1. 需要先安装最新的 `pandoc`(2.18+),最好配置到 PATH 环境变量,或者设置界面指定路径。
参考地址:[https://pandoc.org/installing.html](https://pandoc.org/installing.html)
2. 在 Obsidian 插件市场,搜索 `obsidian-enhancing-export` 进行安装。

Expand Down
26 changes: 15 additions & 11 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// noinspection NpmUsedModulesInstalled

import esbuild from 'esbuild';
import process from 'process';
import builtins from 'builtin-modules';
import { relative } from 'path';
import { rm } from 'fs/promises'
import { exec } from 'child_process';
import { copy } from 'esbuild-plugin-copy';
import { config } from 'dotenv';

Expand All @@ -9,6 +14,10 @@ config({ path: '.env' });

const { OUT_DIR } = process.env;

await rm('dist', { force: true, recursive: true })
if (!relative(OUT_DIR, process.cwd()).startsWith('..')) {
exec(process.platform === 'win32'? `mklink /J dist ${OUT_DIR}` : `ln -s ${OUT_DIR} dist`)
}


const banner =
Expand All @@ -24,12 +33,8 @@ esbuild.build({
banner: {
js: banner,
},
entryPoints: [
'./src/main.ts',
'./styles.css'
],
entryPoints: ['src/main.ts',],
entryNames: '[name]',
outbase: 'src',
bundle: true,
external: [
'obsidian',
Expand Down Expand Up @@ -63,18 +68,17 @@ esbuild.build({
logLevel: 'info',
sourcemap: prod ? false : 'inline',
// sourcemap: 'both',
// sourceRoot: './src',
// sourceRoot: 'src',
minify: prod,
treeShaking: true,
tsconfig: 'tsconfig.json',
plugins: [
copy({
assets: [
{
from: ['./manifest.json'],
to: './',
},
{ from: ['./manifest.json'], to: './', },
{ from: ['./styles.css'], to: './', },
]
})
],
outdir: OUT_DIR ?? 'dist',
outdir: 'dist',
}).catch(() => process.exit(1));
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-enhancing-export",
"name": "Obsidian Enhancing Export",
"version": "1.0.6",
"version": "1.0.7",
"minAppVersion": "0.12.0",
"description": "This is a enhancing export plugin for Obsidian. It allows to export to formats like Html, DOCX, ePub and PDF or Markdown(Hugo) etc.",
"author": "YISH",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "obsidian-enhancing-export",
"version": "1.0.6",
"version": "1.0.7",
"description": "This is a enhancing export plugin for Obsidian. It allows to export to formats like Html, DOCX, ePub and PDF or Markdown(Hugo) etc.",
"main": "main.js",
"main": "dist/main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "node esbuild.config.mjs production",
Expand Down
30 changes: 10 additions & 20 deletions src/export_command_templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default {
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" --self-contained --metadata title="${currentFileName}" -s -o "${outputPath}" -t html',
customArguments:
'--mathjax="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg-full.js"',
customArguments: '--mathjax="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg-full.js"',
extension: '.html',
},
'PDF': {
Expand All @@ -51,64 +50,55 @@ export default {
'Word (.docx)': {
name: 'Word (.docx)',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t docx',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t docx',
extension: '.docx',
},
'OpenOffice': {
name: 'OpenOffice',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t odt',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t odt',
extension: '.odt',
},
'RTF': {
name: 'RTF',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t rtf',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t rtf',
extension: '.rtf',
},
'Epub': {
name: 'Epub',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t epub',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t epub',
extension: '.epub',
},
'Latex': {
name: 'Latex',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t latex',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t latex',
extension: '.latex',
},
'Media Wiki': {
name: 'Media Wiki',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t mediawiki',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t mediawiki',
extension: '.mediawiki',
},
'reStructuredText': {
name: 'reStructuredText',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t rst',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t rst',
extension: '.rst',
},
'Textile': {
name: 'Textile',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t textile',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t textile',
extension: '.textile',
},
'OPML': {
name: 'OPML',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t opml',
arguments: '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t opml',
extension: '.opml',
},
'Custom': {
Expand Down
Loading

0 comments on commit 8858fa4

Please sign in to comment.