rstudio / revealjs

R Markdown Format for reveal.js Presentations
Other
327 stars 85 forks source link

Set good default for `toc-depth` and `toc-title` when using pandoc TOC #123

Open cderv opened 3 years ago

cderv commented 3 years ago

Currently we have the toc variable in the template https://github.com/rstudio/revealjs/blob/c4d57b90e56ea8f2097d112db7308ade0acc3bbb/inst/rmarkdown/templates/revealjs_presentation/resources/default.html#L518-L522

It can be activated using

output: 
  revealjs::revealjs_presentation:
    pandoc_args: "--toc"

We need to add the toc: true argument to the function. But it is quite scarce for now as it will just add a slide with TOC content.

Pandoc's current template is better and offer to customize the toc-title that we are missing https://github.com/jgm/pandoc/blob/d133d737ae4a9f37d0eb6361b3b367157d3dc3bf/data/templates/default.revealjs#L63-L72

toc-title is supported in template since 2.14 only: https://github.com/jgm/pandoc/commit/96d384ac9e4458d6067a85a9347bf9d79d131f2d (https://github.com/jgm/pandoc/pull/7171)

So we need to at least update that to the template.

And with this maybe #69 is not needed.

cderv commented 3 years ago

Thoughts about defaults:

toc = FALSE like in html_document(). Adding a TOC slide should be only when user decides

toc_depth = 1 could be a good default to only show on TOC slide the main headers. But that supposes h1 are used # for slides (slide_level = 2). So maybe toc_depth should default to slide-level - 1, and to 1 if slide_level = 0 is used 🤔

Do we want to add a default toc-title value like "Outline" ? Or should it be user provided only ? Also, should we add it as argument in the function ? It could always be set using toc-title in YAML header but toc and toc_depth are argument in html_document() already. Not toc_title

cderv commented 3 years ago

toc_depth = slide_level - 1 does not work if slides only contains the slide level header (like the skeleton only using ##). pandoc default is 3 but it is not ideal.

I'll take more time to think about this and just add the variables for now.

cderv commented 3 years ago

127 brings support to the variable. We need to use good default now with maybe bringing toc-title as an argument of the output format function