写在前面
Q:Pandoc是什么?
A:格式转换工具,支持多种格式转换。具体可以参考 Pandoc - About pandoc
Q:Pandoc怎么用?
A:命令行操作。Obsidian也有对应的Pandoc插件,本质上还是调用了Pandoc.exe
Get Started
使用命令行工具,进入pandoc.exe所在的路径
Convert Markdown to HTML (terminal in, terminal out)
- 输入
pandoc
- type the word
ctrl+z
enter
Convert HTML to Markdown (terminal in, terminal out)
- 输入
pandoc
- type
-f html -t markdown
- type HTML
ctrl+z
enter
Convert Markdown to HTML (file in, file out)
- 输入
pandoc
- type
xxx.md -f markdown -t html -s -o xxx.html
- The filename xxx.md tells pandoc which file to convert.
- The -s option says to create a “standalone” file, with a header and footer, not just a fragment.
- And the -o xxx.html says to put the output in the file xxx.html.
- Note that we could have omitted -f markdown and -t html, since the default is to convert from markdown to HTML, but it doesn’t hurt to include them.
Convert Markdown to LaTeX (file in, file out)
- type
pandoc xxx.md -f markdown -t latex -s -o xxx.tex
- or just use
pandoc xxx.md -s -o xxx.tex
Convert Markdown to PDF (file in, file out)
- If you want to create a PDF, you’ll need to have LaTeX installed.
- type
pandoc xxx.md -s -o xxx.pdf
Get help
- If you forget an option, or forget which formats are supported, you can always do
pandoc --help
to get a list of all the supported options.
- User's Guide
Obsidian中的Pandoc插件
-
使用命令调用ob中的pandoc插件
-
支持转换的格式有限(markdown to xxx)
-
插件设置
-
pandoc path: /xxxx/pandoc.exe
-
extra pandoc arguments(用来指定模板)
-
--metadata bibliography=/Users/username/Dropbox/library.json
-
--citeproc
-
--csl=/Users/username/Dropbox/mla.csl
-
--reference-doc=/Users/username/Dropbox/template.docx