Skip to content

Commit

Permalink
initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mokeyish committed May 2, 2022
0 parents commit 2eb802f
Show file tree
Hide file tree
Showing 37 changed files with 20,545 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# export to obsidian plugin directory directly?
OUT_DIR="./dist"
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/dist
/node_modules
/lua/main.lua
/.env.local
/.idea
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 YISH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Obsidian Enhancing Export Plugin

English | [中文](./README_zh-CN.md)

This is an enhancing export plugin base on `Pandoc` for Obsidian ([https://obsidian.md/](https://obsidian.md/)). It's allow you to export to formats like `Markdown``Markdown (Hugo)``Html``docx``Latex` etc.

Where `Markdown``Markdown (Hugo)``Html` will export and its media resource together.

**Note:** `Markdown``Markdown (Hugo)``Html` are tested in Mac OS、Window、Linux as I used it for myself, others are not tested well.

## Screen shot

- Export view,click on `Export to ......` on file menu.
![](screenshot/exportview_en-US.png)
- Setting view
![](screenshot/settingview_en-US.png)

## 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.

See more details in [https://pandoc.org/installing.html](https://pandoc.org/installing.html)

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

## Custom 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.

## Variables

You can use `${variables}` in custom export command, their values are:

| Key | Value |
| ------------------------ | ------------------------------------------------------------ |
| `${outputPath}` | Output file path after export. For example, if your export to location `/User/aaa/Documents/test.pdf`, then `${outputDir}` will be replace that path. |
| `${outputDir}` | Output directory of saved exported file,It will be `/User/aaa/Documents` in above case. |
| `${outputFileName}` | File name (without extension) of the saved exported file. It will be `test` in above case. |
| `${outputFileFullName}` | File name (with extension) of the saved exported file. It will be `test.pdf` in above case. |
| `${currentPath}` | Path of currently edited file. For example, if your are editing `/User/aaa/Documents/readme.md`, the the value will be `/User/aaa/Documents/readme.md`. |
| `${currentDir}` | Current directory of currently edited file, It will be`/User/aaa/Documents` in above case. |
| `${currentFileName}` | Filename without extension of currently edited file, It will be `readme` in above case. |
| `${currentFileFullName}` | Filename with extension of currently edited file. It will be `readme.md` in above case. |

## Finally

- Welcome to provide more command templates.
- Feel free to file an issue for any questions.
42 changes: 42 additions & 0 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Obsidian Enhancing Export Plugin

[English](./README.md) | 中文

这是一个基于 Pandoc 的 Obsidian 加强版导出插件。提供了基本的导出格式:Markdown 、Markdown(Hugo [https://gohugo.io/](https://gohugo.io/))、Html、docx、Latex等。
其中 Markdown 、Markdown(Hugo)、Html 会把媒体资源一并导出。

**注意:**目前自用的就是 Markdown 、Markdown(Hugo)、Html,在 Mac OS、Windows、Linux 可正常使用,其他未经严格测试。

## 界面截图
- 导出界面,在文件菜单上点击 `导出为......`
![](screenshot/exportview_zh-CN.png)
- 设置界面
![](screenshot/settingview_zh-CN.png)

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

## 自定义命令

本插件是支持自定义导出命令的,在设置界面,点击添加按钮,选择 `Custom` 作为模板,即可新增一个自定义导出的配置了。

### 变量
你可以使用 `${variable}` 在自定义导出的命令中。它们的值是:

| 变量名 ||
| -- | -- |
| `${outputPath}` |导出路径,例如,你的导出位置是:`/User/aaa/Documents/test.pdf` ,则 `${outputDir}` 会替换为那个路径。|
| `${outputDir}` | 导出目录,按上面的例子,它会被替换为 `/User/aaa/Documents`|
| `${outputFileName}` | 没有扩展名的文件名,按上面的例子,它会被替换为 `test`|
| `${outputFileFullName}` | 文件的全名,按上面的例子,它会被替换为 `test.pdf`|
| `${currentPath}` | 当前文件路径,例如当前的文件位置是 `/User/aaa/Documents/readme.md`,那么它会被替换为这个文件的位置。 |
| `${currentDir}` | 当前文件所在目录,按上面的例子,值为 `/User/aaa/Documents`|
| `${currentFileName}` | 当前文件不带扩展名的名字,值是 `readme` |
| `${currentFileFullName}` | 当前文件全名,值是 `readme.md`|

## 最后

- 欢迎提供更多命令模板。
- 有问题可以提交 Issue 给我。
83 changes: 83 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import esbuild from 'esbuild';
import process from 'process';
import builtins from 'builtin-modules';
import { copy } from 'esbuild-plugin-copy';
import { config } from 'dotenv';

config({ path: '.env.local' });
config({ path: '.env' });

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
*/
`;

const prod = (process.argv[2] === 'production');

esbuild.build({
banner: {
js: banner,
},
entryPoints: [
'./src/main.ts',
'./styles.css'
],
entryNames: '[name]',
outbase: 'src',
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/closebrackets',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/comment',
'@codemirror/fold',
'@codemirror/gutter',
'@codemirror/highlight',
'@codemirror/history',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/matchbrackets',
'@codemirror/panel',
'@codemirror/rangeset',
'@codemirror/rectangular-selection',
'@codemirror/search',
'@codemirror/state',
'@codemirror/stream-parser',
'@codemirror/text',
'@codemirror/tooltip',
'@codemirror/view',
...builtins],
loader: { '.json': 'file' },
format: 'cjs',
watch: !prod,
target: 'es2021',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
// sourcemap: 'both',
// sourceRoot: './src',
minify: prod,
treeShaking: true,
plugins: [
copy({
assets: [
{
from: ['./manifest.json'],
to: './',
},{
from: ['./lua/utf8_filenames.lua', './lua/polyfill.lua','./lua/url.lua', './lua/markdown.lua', './lua/markdown+hugo.lua'],
to: ['./lua/.'],
}
]
})
],
outdir: OUT_DIR ?? 'dist',
}).catch(() => process.exit(1));
5 changes: 5 additions & 0 deletions lua/markdown+hugo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package.path=package.path..";" ..debug.getinfo(1).source:match("(.*[/\\])"):sub(2) .. "?.lua"

Mode='hugo'

require('markdown')
Loading

0 comments on commit 2eb802f

Please sign in to comment.