JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
823 stars 94 forks source link

[FR] Can Weave include a Table of Contents in the HTML output #420

Open 00krishna opened 3 years ago

00krishna commented 3 years ago

description

This is more of a question than a request. But I was wondering if it is possible to include a table of contents in the HTML outputs from the weave() command? This way it is easier to navigate around a document and see the sections, instead of manually scrolling.

I checked other issues and there was a reference to someone asking for control of the table of contents from pandoc_options, however in looking at the documentation I did not see any explanation about using pandoc_options for setting the table of contents. I saw that pandoc_options was mentioned, but it was not really elaborated on.

Hence, I was just wondering if there is a way to include a TOC or if there is an example of include a TOC that I can emulate. Thanks.

vjd commented 3 years ago

you can already include table of contents by passing in pandoc_options=[] where you can pick most options from https://pandoc.org/MANUAL.html#options I think

weave("./test.jmd", doctype="pandoc2html", pandoc_options = ["--toc", "--toc-depth= 3", "--number-sections", "--self-contained"])

However, It would be nice if the pandoc2html output format could keep the julia syntax highlighting and not break the table rendering as seen in the default html output.

00krishna commented 3 years ago

@vjd Oh this is very helpful. Yeah, I see how the pandoc options work now. I tested it out and the syntax highlighting seems to work for me. I wonder if that is simply a matter of including some library in the header of the HTML file. Hmm, there must be a way to include that either through Weave.jl or through some script to add the library to the HTML file that comes out of Weave?

xgdgsc commented 2 years ago

With the same pandoc options as https://github.com/JunoLab/Weave.jl/issues/420#issuecomment-824153525 I don' t get toc, what could be the reason?