Pandoc格式转换(常见word转markdown)

Pandoc是一个强大的文件格式转换工具,能够轻松转换Markdown、HTML、LaTeX和Word docx等多种格式。使用选项如`-f`、`-t`和`-o`指定输入和输出格式,并通过`--extract-media`提取图片。例如,可以将docx文件转换为markdown并保存图片。转换PDF时需要安装LaTeX引擎,且默认使用UTF-8编码。

Pandoc 支持不同格式文件的转换:包括 Markdown, HTML, LaTeX,Word docx。

常见格式

格式说明说明
pptxpowerpoint输出
docxword输入/输出
pdfpdf输出
htmlhtml输入/输出
jsonJSON version of native AST输入/输出
markdownPandoc’s Markdown输入/输出
markdown_mmdMultiMarkdown输入/输出
markdown_phpextra(PHP Markdown Extra输入/输出
markdown_strictoriginal unextended Markdown输入/输出

选项

–list-input-formats 查看输入格式
–list-output-formats 查看输出格式
-f 指定输入格式
-t 指定输出格式
-o 指定输出文件

-p, --preserve-tabs
-s, --standalone 输出选项。输出单文件 (pdf, epub, epub3, fb2, docx, odt 输出格式).
–extract-media=DIR 输入选项。读取文件时,将源文件内容中的图片指定DIR目录

格式转换例子

pandoc -f markdown -t latex hello.txt
pandoc -f docx -t markdown --extract-media ./images -o test.md test.docx
pandoc -f docx -t markdown --extract-media ./images -o test.md e:\test.docx
pandoc test.txt -o test.pdf
pandoc -f html -t markdown --request-header User-Agent:“Mozilla/5.0” https://www.fsf.org

说明:
pandoc默认使用 LaTeX生成PDF,需要安装LaTeX 引擎。

字符编码

输入输出默认为UTF-8编码 。如果不是,则实用管道进行编码

iconv -t utf-8 input.txt | pandoc | iconv -f utf-8

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值