overview TOC: only chapter headings by default, two columns with sub-headings
The overview table of contents now lists only top-level (#) headings by
default. Adding {data-overview-subheadings=true} to the overview
heading opts in to the ## sub-headings below their chapters, which are
then laid out in two CSS columns (chapters kept intact across column
breaks).
Change-Id: Ic916c07b5479e8d19fd942e9151b0a471bf039a4
diff --git a/inst/reveal.js-5.2.1/dist/theme/ids.css b/inst/reveal.js-5.2.1/dist/theme/ids.css
index 5ae8600..16c8f5e 100644
--- a/inst/reveal.js-5.2.1/dist/theme/ids.css
+++ b/inst/reveal.js-5.2.1/dist/theme/ids.css
@@ -1074,6 +1074,13 @@
padding: 0 0 0 1.1em;
font-weight: normal;
}
+.reveal .ids-overview-toc.with-subheadings {
+ columns: 2;
+ column-gap: 2.5em;
+}
+.reveal .ids-overview-toc.with-subheadings > li {
+ break-inside: avoid;
+}
.reveal .ids-overview-toc ul li {
margin: 0.18em 0;
}
diff --git a/inst/rmarkdown/templates/revealjs_presentation/resources/default.html b/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
index a557cf6..9bda0eb 100644
--- a/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
+++ b/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
@@ -978,9 +978,11 @@
$endif$
<script>
// Slides whose (only) heading is "Overview" or "Überblick" are
- // automatically populated with a table of contents built from the deck's
- // h1/h2 slide headings, replacing whatever body content the slide had
- // (ported from the Google Docs slide workflow). Styling in the ids theme.
+ // automatically populated with a table of contents of the deck's h1 slide
+ // headings, replacing whatever body content the slide had (ported from the
+ // Google Docs slide workflow). By adding {data-overview-subheadings=true}
+ // to the heading, h2 sub-headings are included below their chapters and
+ // the list is laid out in two columns. Styling in the ids theme.
(function () {
var TITLES = ['overview', 'überblick'];
@@ -998,13 +1000,17 @@
if (!isOverviewSlide(target) || target.dataset.tocDone) return;
target.dataset.tocDone = '1';
var heading = target.querySelector('h1,h2');
+ var includeSub = (heading.getAttribute('data-overview-subheadings') || '')
+ .toLowerCase() !== 'false'
+ && heading.hasAttribute('data-overview-subheadings');
var list = document.createElement('ul');
list.className = 'ids-overview-toc';
+ if (includeSub) list.classList.add('with-subheadings');
var subList = null;
slides.forEach(function (slide) {
if (slide === target || !slide.id || isOverviewSlide(slide)) return;
var h = slide.querySelector('h1,h2');
- if (!h) return;
+ if (!h || (h.tagName !== 'H1' && !includeSub)) return;
var link = document.createElement('a');
link.href = '#/' + slide.id;
link.textContent = h.textContent;