Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty TOC element are not removed when slide is created by --- #11146

Closed
cderv opened this issue Oct 22, 2024 · 0 comments · Fixed by #11147
Closed

Empty TOC element are not removed when slide is created by --- #11146

cderv opened this issue Oct 22, 2024 · 0 comments · Fixed by #11147
Assignees
Labels
bug Something isn't working revealjs Issues with the revealjs format
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented Oct 22, 2024

---
title: "My Title"
format: revealjs
editor: source
toc: true
---

## Section 1

Slide 1 of section 1. Should show up in the TOC as a bullet point.

---

Slide 2 of section 1. Should **not** show up in the TOC as a bullet point.

## Section 2

Slide 1 of section 2. Should show up in the TOC as a bullet point.

The second slide should not be in TOC

Image

This was supposed to be fixed in #3671 but it is incompleted because it does not handle --- as slide delimiter.

const handleUntitledSlidesInToc = (doc: Document) => {
// remove from toc all slides that have no title
const tocEntries = Array.from(doc.querySelectorAll(
'nav[role="doc-toc"] a[href^="#/"]',
));
for (const tocEntry of tocEntries) {
const tocEntryEl = tocEntry as Element;
if (tocEntryEl.textContent.trim() === "") {
tocEntryEl.parentElement?.remove();
}
}
};

Empty bullet point as no empty href <a> element...

<nav role="doc-toc"> 
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#/section-1" id="/toc-section-1">Section 1</a></li>
<li></li>
<li><a href="#/section-2" id="/toc-section-2">Section 2</a></li>
</ul>
</nav>

I think we can check for empty textContent on the ul > li directly and remove if no text.

@cderv cderv added bug Something isn't working revealjs Issues with the revealjs format labels Oct 22, 2024
@cderv cderv added this to the v1.6 milestone Oct 22, 2024
@cderv cderv self-assigned this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working revealjs Issues with the revealjs format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant