工具
- pandoc
- wkhtmltopdf
- Python & pip | Anaconda
注:
- 以上工具均为横
夸跨 Windows,Linux 和 Mac OS X 平台,因此在 3 个平台均可搭建环境。 - Anaconda 安装包含 Python 和 pip,以及一些常用的包,一劳永逸
安装
下载 pandoc,wkhtmltopdf 和 Anaconda
安装完后确保将其可执行文件添加到系统环境变量
C:\Users\linjinhui\Desktop\pandoc
λ pandoc --version
pandoc 1.16.0.2
Compiled with texmath 0.8.4.1, highlighting-kate 0.6.1.
Syntax highlighting is supported for the following languages:
abc, actionscript, ada, agda, apache, asn1, asp, awk, bash, bibtex, boo, c,
changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css,
curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd,
eiffel, email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go,
haskell, haxe, html, idris, ini, isocpp, java, javadoc, javascript, json,
jsp, julia, kotlin, latex, lex, lilypond, literatecurry, literatehaskell,
llvm, lua, m4, makefile, mandoc, markdown, mathematica, matlab, maxima,
mediawiki, metafont, mips, modelines, modula2, modula3, monobasic, nasm,
noweb, objectivec, objectivecpp, ocaml, octave, opencl, pascal, perl, php,
pike, postscript, prolog, pure, python, r, relaxng, relaxngcompact, rest,
rhtml, roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql,
sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl, xml, xorg, xslt, xul,
yacc, yaml, zsh
Default user data directory: C:\Users\linjinhui\AppData\Roaming\pandoc
Copyright (C) 2006-2015 John MacFarlane
Web: http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
C:\Users\linjinhui\Desktop\pandoc
λ python --version
Python 2.7.8 :: Anaconda 2.1.0 (64-bit)
C:\Users\linjinhui\Desktop\pandoc
λ pip --version
pip 1.5.6 from C:\Anaconda\lib\site-packages (python 2.7)
C:\Users\linjinhui\Desktop\pandoc
λ wkhtmltopdf --version
wkhtmltopdf 0.12.3.1 (with patched qt)
C:\Users\linjinhui\Desktop\pandoc
λ
使用
- 写 Markdown 文档,以 setup_linux_driver_enviroment.md 文档为例
- 将 Markdown 文档装换成 Word:pandoc后面接着的第1个参数为输入源文件,
- o
紧接着目标输出文件,-c
紧接着为css
样式文件
pandoc setup_linux_driver_enviroment.md -o setup_linux_driver_enviroment.docx -c markdown.css
- 将 Markdown 转成 HTML:
pandoc setup_linux_driver_enviroment.md -o setup_linux_driver_enviroment.html -c markdown.css
- 将 HTML 转成 PDF:
wkhtmltopdf setup_linux_driver_enviroment.html setup_linux_driver_enviroment.pdf
注:推荐一个在线转换的工具http://www.athenapdf.com/
- 将 HTML 转成 PNG:
wkhtmltopdf setup_linux_driver_enviroment.html setup_linux_driver_enviroment.png
注:其他格式转换可以用 SmallPDF。
美化
- 参考 参考链接,加入不同的 CSS 样式
- 修改 CSS 样式,在
标签下加入简单的移动端自适应
参考链接
- Markdown写作进阶:Pandoc入门浅谈
- Getting started with pandoc
- Markdown CSS
- Markdown css theme collection
- Pandoc Configuration and Support Files