將大型 Markdown 單一檔案轉換為多個 HTML

將大型 Markdown 單一檔案轉換為多個 HTML

我需要一個工具或靜態網站產生器,可以從以下位置產生網站(多個 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 文件以獲得良好的預設格式。

相關內容