markdown 轉(zhuǎn) docx 及 pdf 轉(zhuǎn) docx

pdf 轉(zhuǎn)換為 docx

中文轉(zhuǎn)換時(shí)的亂碼

通過(guò) -V 參數(shù)指定中文字體

-V mainfont="Microsoft YaHei"

如果還是不行,請(qǐng)?jiān)囋囕斎耄?/p>

-V CJKmainfont=KaiTi

注意:-V--variable 的縮寫(xiě)。

其他格式的文件轉(zhuǎn)化為 docx

  1. Word docx:

    pandoc -s MANUAL.txt -o example29.docx
    
  2. LaTeX math to docx:

    pandoc -s math.tex -o example30.docx
    
  3. Markdown to docx:

    pandoc -s m.md -o m.docx
    
  4. Docx with a reference docx:

    pandoc --reference-doc twocolumns.docx -o UsersGuide.docx MANUAL.txt
    

解決中文亂碼

pandoc -V mainfont="Microsoft YaHei" --reference-doc twocolumns.docx -o UsersGuide.docx MANUAL.txt

這里是以 twocolumns.docx 為模板將 MANUAL.txt 寫(xiě)入到 UsersGuide.docx,使得UsersGuide.docxtwocolumns.docx 具有相同的格式。
更多內(nèi)容參考:Pandoc Demos

其他

Docx to markdown, including math:

pandoc -s example30.docx -t markdown -o example35.md

EPUB to plain text:

pandoc MANUAL.epub -t plain -o example36.text

If no input-files are specified, input is read from stdin. Output goes to stdout by default. For output to a file, use the -o option:

pandoc -o output.html input.txt

By default, pandoc produces a document fragment. To produce a standalone document (e.g. a valid HTML file including <head> and <body>), use the -s or -- standalone flag:

pandoc -s -o output.html input.txt

Character encoding

Pandoc uses the UTF-8 character encoding for both input and output. If your local character encoding is not UTF-8, you should pipe input and output through iconv:

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

Note that in some output formats (such as HTML, LaTeX, ConTeXt, RTF, OPML, DocBook, and Texinfo), information about the character encoding is included in the document header, which will only be included if you use the -s/--standalone option.

vscode 中的 pandoc

在 Markdown 開(kāi)頭的位置添加如下內(nèi)容:

---
title: "文檔"
author: XXXX
date: 2019/8/22
output:
  word_document:
    toc: true
    reference_doc: demo.docx
---

便可以直接將 .md 文檔轉(zhuǎn)換為以 demo.docx 為模板的 .docx 文檔。在 Markdown 的預(yù)覽區(qū)域,鼠標(biāo)右鍵選擇 Pandoc

總結(jié):

  • markdown 轉(zhuǎn)換為 html:pandoc README.md -o README.html
  • Markdown 轉(zhuǎn) word:pandoc README.md -o README.docx
  • markdown 轉(zhuǎn)換為 pdf:pandoc README.md -o README.pdf --pdf-engine=xelatex(latex之前是雙短橫線)
    • 在執(zhí)行本條命令之前,需要首先安裝 latex 編譯器,對(duì)于 windows 用戶,比如安裝 ctex 安裝組件;
  • pandoc -s C.docx -t markdown -o C.md:可以將 docx 轉(zhuǎn)換為 markdown
  • 各種例子

參考資料:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
禁止轉(zhuǎn)載,如需轉(zhuǎn)載請(qǐng)通過(guò)簡(jiǎn)信或評(píng)論聯(lián)系作者。

相關(guān)閱讀更多精彩內(nèi)容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom閱讀 3,224評(píng)論 0 3
  • 明顯已經(jīng)過(guò)了憤青的年紀(jì),不時(shí)會(huì)指著一臉正義憤怒吶喊的憂國(guó)憂民分子調(diào)侃地說(shuō)“看,憤青”,輕佻地像“看,灰機(jī)”一樣。也...
    李子李子短信閱讀 673評(píng)論 0 8
  • 本文主要講述golang的gui庫(kù)andlabs/ui使用。目前該庫(kù)還不是很完善。 環(huán)境說(shuō)明: 系統(tǒng):Win10 ...
    小墨馬閱讀 8,478評(píng)論 4 52
  • ——挑戰(zhàn)自己,改變自己,感恩有你 20171215 褚旭踐行自己承諾90天記錄(35/90) [奮斗]未來(lái)90天,...
    褚洪嘉閱讀 357評(píng)論 0 0
  • 杯空,人走,獨(dú)自之時(shí)。望著窗外的景致,似曾產(chǎn)生的情感,想著如何同你道來(lái)。 偷得這一番空閑,從前會(huì)多感謝:喝...
    悄吟綿亙_閱讀 353評(píng)論 0 0

友情鏈接更多精彩內(nèi)容