DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Pandoc笔记


On Windows

安装:使用管理员权限运行PowerShell并执行choco install pandoc;

使用:pandoc frnote.md -o frnote.docx

Pandoc根据输入输出文件扩展名确定格式,不需要通过参数指定。

On Linux

Mint 17上安装pandoc: sudo aptitude install pandoc;

将markdown文件转为MS Word docx文件: pandoc -f markdown -t docx -o 开发者手册.docx dev-manual.md;

Pandoc的多级列表

今天在用markdown写多级列表的时候发现markdown不支持多级列表, 找了一番发现Pandoc是个比较好的替代工具。 功能强(支持多级列表,配上插件可以生成pdf和docx文件),开源(GPL)。

Hello World Demo (multi-level ordered list)

  1. 下载Pandoc for Windows;

  2. 写一个简单的示例demo.txt,内容如下:

  1. title one i. sub one

a. sub sub one

a. sub sub two i. sub two 1. title two 1. title three i. sub three one i. sub three two

  1. demo.txt所在路径下运行"pandoc -o demo.html demo.txt",会在当前目录下生成demo.html文件,效果如下:

title one sub one sub sub one sub sub two sub two title two title three sub three one sub three two

采用pandoc语法写多级列表的格式是:第2级列表行首缩进4格,以"i. "开头,第3级多加4个空格,以"a. "开头。

Multi-level bullet list

demo.txt内容如下:

  • this is list line 1
  • this is sub list 1
  • this is sub sub list 1
  • this is sub list 2
  • this is list 2

输出结果:

this is list line 1 this is sub list 1 this is sub sub list 1 this is sub list 2 this is list 2

注意:

  • GBK编码的文件中如果有中文,pandoc会报错退出,如果一定要显示中文,需要保存为UTF-8格式。


Published

Dec 7, 2012

Last Updated

Dec 7, 2012

Category

Tech

Tags

  • markdown 6
  • multi-level list 1
  • pandoc 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor