Skip to content

Commit 8e429f0

Browse files
committed
fix(revealjs): Empty title slide element shouldn't be shown in TOC
This complements initial fix from #3671 to support `---` as a slide separator
1 parent a2a22e5 commit 8e429f0

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

news/changelog-1.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ All changes included in 1.6:
4545
- ([#6012](https://github.com/quarto-dev/quarto-cli/issues/6012)): Add styling for `kbd` element in Revealjs slides.
4646
- ([#10887](https://github.com/quarto-dev/quarto-cli/issues/10887)): Updating default Mathjax used from 2.7.0 to 2.7.9.
4747
- ([#9999](https://github.com/quarto-dev/quarto-cli/issues/9999)): Fix spacing problems of different size elements in columns.
48+
- ([#11146](https://github.com/quarto-dev/quarto-cli/issues/11146)): Fix issue with slide created with `---` and having no title showing up in TOC. Now they don't show up as slide created with empty header e.g. `## `.
4849

4950
## `typst` Format
5051

src/format/reveal/format-reveal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ export function revealjsFormat() {
379379
const determineRevealLogo = (format: Format): string | undefined => {
380380
const brandData = format.render.brand?.processedData;
381381
if (brandData?.logo) {
382-
const keys: ("medium" | "small" | "large")[] = ["medium", "small", "large"]
382+
const keys: ("medium" | "small" | "large")[] = ["medium", "small", "large"];
383383
// add slide logo if we have one
384384
for (const size of keys) {
385385
const logoInfo = brandData.logo[size];
@@ -582,12 +582,12 @@ const handleInvisibleSlides = (doc: Document) => {
582582
const handleUntitledSlidesInToc = (doc: Document) => {
583583
// remove from toc all slides that have no title
584584
const tocEntries = Array.from(doc.querySelectorAll(
585-
'nav[role="doc-toc"] a[href^="#/"]',
585+
'nav[role="doc-toc"] ul > li',
586586
));
587587
for (const tocEntry of tocEntries) {
588588
const tocEntryEl = tocEntry as Element;
589589
if (tocEntryEl.textContent.trim() === "") {
590-
tocEntryEl.parentElement?.remove();
590+
tocEntryEl.remove();
591591
}
592592
}
593593
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
format: revealjs
3+
toc: true
4+
_quarto:
5+
tests:
6+
revealjs:
7+
ensureHtmlElements:
8+
-
9+
- 'nav[role="doc-toc"] ul > li:nth-child(1) > a[href$="section-1"]'
10+
- 'nav[role="doc-toc"] ul > li:nth-child(2) > a[href$="section-2"]'
11+
-
12+
- 'nav[role="doc-toc"] ul > li:nth-child(3)'
13+
---
14+
15+
## Section 1
16+
17+
Should show up in the TOC as a bullet point.
18+
19+
---
20+
21+
No title and should not be
22+
23+
## Section 2
24+
25+
Should show up in the TOC as a bullet point.
26+
27+
##
28+
29+
No title and should not be in the TOC

0 commit comments

Comments
 (0)