Skip to content

Commit

Permalink
🎨 remove polyfill.ts; fix linting; bundle the lua files in main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mokeyish committed May 7, 2022
1 parent cfb82d8 commit 2aae92f
Show file tree
Hide file tree
Showing 25 changed files with 672 additions and 651 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tag-version-prefix=""
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
quoteProps: preserve
trailingComma: es5
arrowParens: avoid

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Where `Markdown`、`Markdown (Hugo)`、`Html` will export and its media resource

2. Search `obsidian-enhancing-export` in the community plugin of obsidian, and install it.

## Custom export commands
## Customize export commands

You can custom your export command by yourself, click `add` in the plugin setting view and then choose template `custom` to add new custom configuration.
You can customize your export command by yourself, click `add` in the plugin setting view and then choose template `custom` to add new custom configuration.

## Variables

Expand All @@ -44,5 +44,5 @@ You can use `${variables}` in custom export command, their values are:

## Finally

- Welcome to provide more command templates.
- Welcome to provide more command templates to [here](src/export_command_templates.ts).
- Feel free to file an issue for any questions.
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@

## 最后

- 欢迎提供更多命令模板
- 欢迎提供更多命令模板到[这里](src/export_command_templates.ts).
- 有问题可以提交 Issue 给我。
9 changes: 3 additions & 6 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { OUT_DIR } = process.env;
const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
if you want to view the source, please visit the github repository https://github.com/mokeyish/obsidian-enhancing-export .
*/
`;

Expand Down Expand Up @@ -56,7 +56,7 @@ esbuild.build({
'@codemirror/tooltip',
'@codemirror/view',
...builtins],
loader: { '.json': 'file' },
loader: { '.json': 'file', '.lua': 'binary' },
format: 'cjs',
watch: !prod,
target: 'es2021',
Expand All @@ -72,10 +72,7 @@ esbuild.build({
{
from: ['./manifest.json'],
to: './',
},{
from: ['./lua/utf8_filenames.lua', './lua/polyfill.lua','./lua/url.lua', './lua/markdown.lua', './lua/markdown+hugo.lua'],
to: ['./lua/.'],
}
},
]
})
],
Expand Down
7 changes: 3 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

{
"id": "obsidian-enhancing-export",
"name": "Obsidian Enhancing Export",
"version": "1.0.1",
"version": "1.0.4",
"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 Hugo.",
"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",
"authorUrl": "https://obsidian.md",
"authorUrl": "https://github.com/mokeyish",
"isDesktopOnly": true
}
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"name": "obsidian-enhancing-export",
"version": "0.12.0",
"description": "This is a enhancing export plugin for Obsidian. It allows to export to formats like DOCX, ePub and PDF or Hugo.",
"version": "1.0.4",
"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",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "node esbuild.config.mjs production"
"build": "node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json",
"lint": "eslint --ext .ts,.js src build",
"lint-fix": "eslint --fix --ext .ts,.js src build gulpfile.js",
"format-check": "prettier --check \"src/**/*.ts\"",
"format-fix": "prettier --write \"src/**/*.ts\""
},
"keywords": [],
"author": "YISH",
"license": "MIT",
"repository": "https://github.com/mokeyish/obsidian-enhancing-export",
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.18.0",
Expand All @@ -20,6 +26,7 @@
"esbuild-plugin-copy": "^1.3.0",
"eslint": "^8.13.0",
"obsidian": "latest",
"prettier": "^2.6.2",
"tslib": "2.3.1",
"typescript": "4.6.3"
}
Expand Down
107 changes: 107 additions & 0 deletions src/export_command_templates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import type { ExportSetting } from './settings';

/*
* Variables
* /User/aaa/Documents/test.pdf
* - ${outputDir} --> /User/aaa/Documents/
* - ${outputPath} --> /User/aaa/Documents/test.pdf
* - ${outputFileName} --> test
* - ${outputFileFullName} --> test.pdf
*
* /User/aaa/Documents/test.pdf
* - ${currentDir} --> /User/aaa/Documents/
* - ${currentPath} --> /User/aaa/Documents/test.pdf
* - ${CurrentFileName} --> test
* - ${CurrentFileFullName} --> test.pdf
*/

export default {
'Markdown': {
name: 'Markdown',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --lua-filter="${pluginDir}/lua/markdown.lua" -s -o "${outputPath}" -t commonmark_x-attributes',
extension: '.md',
},
'Markdown (Hugo)': {
name: 'Markdown (Hugo)',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --lua-filter="${pluginDir}/lua/markdown+hugo.lua" -s -o "${outputPath}" -t commonmark_x-attributes',
extension: '.md',
},
'Html': {
name: 'Html',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --self-contained --metadata title="${currentFileName}" -s -o "${outputPath}" -t html',
customArguments: '--mathjax="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg-full.js"',
extension: '.html',
},
'PDF': {
name: 'PDF',
type: 'pandoc',
arguments:
'-f markdown --resource-path="${currentDir}" --self-contained --metadata title="${currentFileName}" -s -o "${outputPath}" -t pdf',
extension: '.pdf',
},
'Word (.docx)': {
name: 'Word (.docx)',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t docx',
extension: '.docx',
},
'OpenOffice': {
name: 'OpenOffice',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t odt',
extension: '.odt',
},
'RTF': {
name: 'RTF',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t rtf',
extension: '.rtf',
},
'Epub': {
name: 'Epub',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t epub',
extension: '.epub',
},
'Latex': {
name: 'Latex',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t latex',
extension: '.latex',
},
'Media Wiki': {
name: 'Media Wiki',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t mediawiki',
extension: '.mediawiki',
},
'reStructuredText': {
name: 'reStructuredText',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t rst',
extension: '.rst',
},
'Textile': {
name: 'Textile',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t textile',
extension: '.textile',
},
'OPML': {
name: 'OPML',
type: 'pandoc',
arguments: '-f markdown --resource-path="${currentDir}" -s -o "${outputPath}" -t opml',
extension: '.opml',
},
'Custom': {
name: 'Custom',
type: 'custom',
command: 'your command',
},
} as Record<string, ExportSetting>;
41 changes: 20 additions & 21 deletions src/lang/en-US.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,68 @@
import { strTpl } from '../utils';

export default {
preparing: strTpl `generating "${0}" ......`,
preparing: strTpl`generating "${0}" ......`,
exportToOo: 'Export to ......',
settingTabTitle: 'Export Setting',
pandocPath: 'Pandoc path',
pandocPathPlaceholder: '(Auto Detect)',
selectExportFolder: 'Please select an export folder.',
exportSuccessNotice: strTpl `Export file ${0} success!`,
exportCommandOutputMessage: strTpl `Command: ${0}`,
exportErrorOutputMessage: strTpl `Command: ${0},Error:${1}`,
exportSuccessNotice: strTpl`Export file ${0} success!`,
exportCommandOutputMessage: strTpl`Command: ${0}`,
exportErrorOutputMessage: strTpl`Command: ${0},Error:${1}`,
overwriteConfirmationDialog: {
replace: 'Replace',
title: strTpl `"${0}" already exists. Do you want to replace it?`,
message: strTpl `A file or folder with the same name already exists in the folder "${0}". Replacing it will overwrite its current contents.`,
title: strTpl`"${0}" already exists. Do you want to replace it?`,
message: strTpl`A file or folder with the same name already exists in the folder "${0}". Replacing it will overwrite its current contents.`,
},
messageBox: {
yes: 'Yes',
no: 'No',
ok: 'Ok',
cancel: 'Cancel'
cancel: 'Cancel',
},

general: 'General',
name: 'Name',
new: 'New',

add: 'Add',
remove: 'Remove',
rename: 'Rename',
chooseSetting: 'Choose setting',

save: 'Save',

exportDialog: {
title: strTpl `Export to ${0}`,
title: strTpl`Export to ${0}`,
export: 'Export',
},



exportTo: 'Export to',

template: 'Template',

fileName: 'File Name',
type: 'Type',

overwriteConfirmation: 'Overwrite confirmation',

defaultFolderForExportedFile: 'Default Folder for Exported File',
auto: 'Auto',
sameFolderWithCurrentFile: 'Same folder with current file',
customLocation: 'Custom location',
reset: 'Reset',
command: 'Command',

arguments: 'Arguments',
extraArguments: 'Extra arguments',
targetFileExtensions: 'Target file extensions',
targetFileExtensionsTip: '(Separated by whitespace)',

afterExport: 'After Export',

runCommand: 'Run command',
showCommandOutput: 'Show command output',
openExportedFileLocation: 'Open exported file location',
openExportedFile: 'Open exported file',
};
};
4 changes: 2 additions & 2 deletions src/lang/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import zhCN from './zh-CN';
import enUS from './en-US';
import {moment} from 'obsidian';
import { moment } from 'obsidian';

export type Lang = typeof enUS;

Expand All @@ -22,4 +22,4 @@ export default {
}
return this['en-US'];
},
};
};
30 changes: 14 additions & 16 deletions src/lang/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@

import { strTpl } from '../utils';
import type lang from './en-US';


export default ((): typeof lang => {
return {
selectExportFolder: '请选择导出文件夹',
exportSuccessNotice: strTpl `导出文件 ${0} 成功!`,
exportCommandOutputMessage: strTpl `命令:${0}`,
exportErrorOutputMessage: strTpl `命令 ${0},错误:{1}`,
exportSuccessNotice: strTpl`导出文件 ${0} 成功!`,
exportCommandOutputMessage: strTpl`命令:${0}`,
exportErrorOutputMessage: strTpl`命令 ${0},错误:{1}`,
messageBox: {
yes: '是',
no: '否',
ok: '确认',
cancel: '取消'
cancel: '取消',
},
overwriteConfirmationDialog: {
replace: '替换',
title: strTpl `"${0}" 已经存在。您要替换它吗?`,
message: strTpl `"${0}" 文件夹中已有相同的文件或文件夹,若替换,则会覆盖其当前内容。`,
title: strTpl`"${0}" 已经存在。您要替换它吗?`,
message: strTpl`"${0}" 文件夹中已有相同的文件或文件夹,若替换,则会覆盖其当前内容。`,
},
preparing: strTpl `正在生成 "${0}" ......`,
preparing: strTpl`正在生成 "${0}" ......`,
chooseSetting: '选择配置',
save: '保存',
new: '新建',
Expand All @@ -30,17 +28,17 @@ export default ((): typeof lang => {
fileName: '文件名',
overwriteConfirmation: '覆盖提示',
defaultFolderForExportedFile: '默认的导出文件夹',
customLocation: '自定义',
pandocPath: 'Pandoc 路径',
pandocPathPlaceholder: '(自动检测)',
customLocation: '自定义',
pandocPath: 'Pandoc 路径',
pandocPathPlaceholder: '(自动检测)',
sameFolderWithCurrentFile: '与原文件同一目录下',
add: '添加',
afterExport: '导出后',
arguments: '参数',
auto: '自动',
command: '命令',
command: '命令',
exportDialog: {
title: strTpl `导出为 ${0}`,
title: strTpl`导出为 ${0}`,
export: '导出',
},
exportTo: '导出到',
Expand All @@ -56,6 +54,6 @@ export default ((): typeof lang => {
showCommandOutput: '显示命令行删除',
targetFileExtensions: '目标文件扩展名',
targetFileExtensionsTip: '(用空格分开)',
template: '模板'
template: '模板',
};
})();
})();
Loading

0 comments on commit 2aae92f

Please sign in to comment.