overview TOC: exclude References and Appendix chapters

Chapters titled References, Literatur, Literaturverzeichnis, Appendix,
or Anhang (and their sub-slides) are now left out of the overview table
of contents.

Change-Id: I2d4c69ef8cb925113b43c3615416091f463bb8ef
diff --git a/NEWS.md b/NEWS.md
index 829cb18..1c4b61a 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,6 +1,6 @@
 # revealjs.ids (development version)
 
-- Slides titled "Overview" or "Überblick" are now automatically turned into a table of contents (ported from the old Google Docs slide workflow): their body content is replaced at presentation time with a clickable list of all `#` chapter headings. Adding `{data-overview-subheadings=true}` to the heading also includes the `##` sub-headings, laid out in two columns.
+- Slides titled "Overview" or "Überblick" are now automatically turned into a table of contents (ported from the old Google Docs slide workflow): their body content is replaced at presentation time with a clickable list of all `#` chapter headings. Adding `{data-overview-subheadings=true}` to the heading also includes the `##` sub-headings, laid out in two columns. References and appendix chapters (References/Literatur/Literaturverzeichnis/Appendix/Anhang) are excluded, together with their sub-slides.
 
 - Speaker notes (`::: notes`) and timing comments placed before the first heading are now attached to the title slide instead of ending up on a separate empty phantom slide after it, so the title itself can have a time budget and a welcome note (shown in the speaker view and the mobile notes overlay, and included in `slide_timing()` and the pacing timer).
 
diff --git a/R/revealjs_presentation.R b/R/revealjs_presentation.R
index 75d6c23..dab04c7 100644
--- a/R/revealjs_presentation.R
+++ b/R/revealjs_presentation.R
@@ -82,6 +82,18 @@
 #' The function [slide_timing()] computes these totals directly from an
 #' `.Rmd` source file without rendering it.
 #' 
+#' ## Overview slides
+#' 
+#' Like in the original Google Docs slide workflow, a slide titled
+#' "Overview" or "Überblick" is automatically turned into a table of
+#' contents: its body content is replaced at presentation time with a
+#' clickable list of all `#` chapter headings. Adding
+#' `{data-overview-subheadings=true}` to the heading also includes the
+#' `##` sub-headings below their chapters, laid out in two columns.
+#' References and appendix chapters (References/Literatur/
+#' Literaturverzeichnis/Appendix/Anhang) are left out, together with
+#' their sub-slides.
+#' 
 #' ### Search
 #' 
 #' When opt-in, it is possible to show a search box when pressing `CTRL + SHIFT +
diff --git a/README.Rmd b/README.Rmd
index 2ee1375..8193316 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -164,7 +164,7 @@
 (any placeholder content -- replaced automatically)
 ```
 
-To also include the `##` sub-headings below their chapters, add `{data-overview-subheadings=true}` to the heading; the list is then laid out in two columns:
+To also include the `##` sub-headings below their chapters, add `{data-overview-subheadings=true}` to the heading; the list is then laid out in two columns. References and appendix chapters (References/Literatur/Literaturverzeichnis/Appendix/Anhang) are left out, together with their sub-slides.
 
 ``` markdown
 ## Overview {data-overview-subheadings=true}
diff --git a/README.md b/README.md
index a993038..29b35a9 100644
--- a/README.md
+++ b/README.md
@@ -210,7 +210,9 @@
 
 To also include the `##` sub-headings below their chapters, add
 `{data-overview-subheadings=true}` to the heading; the list is then
-laid out in two columns:
+laid out in two columns. References and appendix chapters
+(References/Literatur/Literaturverzeichnis/Appendix/Anhang) are left
+out, together with their sub-slides.
 
 ``` markdown
 ## Overview {data-overview-subheadings=true}
diff --git a/inst/rmarkdown/templates/revealjs_presentation/resources/default.html b/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
index 9bda0eb..062ffa7 100644
--- a/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
+++ b/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
@@ -982,9 +982,11 @@
   // 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.
+  // the list is laid out in two columns. References and appendix chapters
+  // (English and German) are left out. Styling in the ids theme.
   (function () {
     var TITLES = ['overview', 'überblick'];
+    var EXCLUDED = ['references', 'literatur', 'literaturverzeichnis', 'appendix', 'anhang'];
 
     function isOverviewSlide(slide) {
       var h = slide.querySelector('h1,h2');
@@ -1007,10 +1009,15 @@
         list.className = 'ids-overview-toc';
         if (includeSub) list.classList.add('with-subheadings');
         var subList = null;
+        var excluded = false;
         slides.forEach(function (slide) {
           if (slide === target || !slide.id || isOverviewSlide(slide)) return;
           var h = slide.querySelector('h1,h2');
-          if (!h || (h.tagName !== 'H1' && !includeSub)) return;
+          if (!h) return;
+          if (h.tagName === 'H1') {
+            excluded = EXCLUDED.indexOf(h.textContent.trim().toLowerCase()) !== -1;
+          }
+          if (excluded || (h.tagName !== 'H1' && !includeSub)) return;
           var link = document.createElement('a');
           link.href = '#/' + slide.id;
           link.textContent = h.textContent;
diff --git a/man/revealjs_presentation.Rd b/man/revealjs_presentation.Rd
index 62c1182..a903d31 100644
--- a/man/revealjs_presentation.Rd
+++ b/man/revealjs_presentation.Rd
@@ -236,6 +236,9 @@
 clickable list of all \verb{#} chapter headings. Adding
 \code{{data-overview-subheadings=true}} to the heading also includes the
 \verb{##} sub-headings below their chapters, laid out in two columns.
+References and appendix chapters (References/Literatur/
+Literaturverzeichnis/Appendix/Anhang) are left out, together with
+their sub-slides.
 \subsection{Search}{
 
 When opt-in, it is possible to show a search box when pressing \code{CTRL + SHIFT + F}. It will seach in the whole presentation, and highlight matched words. The