![將大型 Markdown 單一檔案轉換為多個 HTML](https://rvso.com/image/1413941/%E5%B0%87%E5%A4%A7%E5%9E%8B%20Markdown%20%E5%96%AE%E4%B8%80%E6%AA%94%E6%A1%88%E8%BD%89%E6%8F%9B%E7%82%BA%E5%A4%9A%E5%80%8B%20HTML.png)
我需要一個工具或靜態網站產生器,可以從以下位置產生網站(多個 HTML)獨特的Markdown 文件,以單獨的部分為基礎(Markdown 標頭)。
例如,我的降價.md:
# Title
## Lesson 1
[...text and content...]
## Lesson 2
[...text and content...]
和產生的結果站點:
- main.html
|
|--- lesson1.html (with link "next")
|
|--- lesson2.html (with link "prev" and "next")
|
我用潘多克(TOC 功能非常有用)並且工作得很好,但我認為 pandoc 不可能做到這一點。一些幫助?
答案1
將文件轉換為 epub 格式,這樣可以將文件拆分為單獨的文件:
pandoc -f markdown -t epub -o myfilename.epub markdown.md
然後,解壓縮 epub 檔案。產生的 .xhtml 檔案將位於 \text 資料夾下。
有趣的選項:
--epub-chapter-level=3 // Header level where file is split
--epub-subdirectory=. // name of the folder with content inside the epub archive
--toc-depth=4 // generate table of contents with this number of header levels
--css=.\pandoc.css // apply CSS styles
查看這個 .css 文件以獲得良好的預設格式。