Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
539 views
in Technique[技术] by (71.8m points)

markdown - Pandoc - Inserting pages before generated Table of Contents

I've been playing around with Pandoc.

Is there anyway to insert pages before the generated Table of Contents?

For example:

  • Title Page
  • Insert Custom Page 001
  • Insert Custom Page 002
  • (Generated) Table of Contents

Many thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I am guessing you want to create a HTML File with Title Page or Header Information. The solution is to do it in more than one Step.

First you compile the Title Page together any other pages to one html.

$ pandoc .1_HEADER.markdown -o header.html

Then you include that header.html before the body:

$ pandoc -s -S --toc -B .header.html .2_Document.markdown -o complete_doc.html

Done.


The pandoc help states it's possibilities to make multi-part documents possible, both -B and -H work, but i think -B is more correct in my case.

  -H FILENAME           --include-in-header=FILENAME                    
  -B FILENAME           --include-before-body=FILENAME                  
  -A FILENAME           --include-after-body=FILENAME                  

In my case i do it with a stylesheet and get a perfect document:

$ pandoc -s -S -c .
esgithub-pandoc.css .1_HEADER.markdown -o header.html
$ pandoc -s -S --toc --toc-depth=2 -c .
esgithub-pandoc.css -B .header.html .2_Document.markdown -o complete_document.html

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...