Skip to content

Plain-text TOC: Can the Table of Contents be made to ignore HTML tags within headings? #9596

Closed Answered by artistofmind
artistofmind asked this question in Q&A
Discussion options

You must be logged in to vote

I figure I should share with you all the simple solution I came up with, or rather stumbled upon.

I noticed HTML headers don’t generate an entry in the TOC, only Markdown ones do. (So Pandoc adds ###, but ignores <h3>.) I now use both, and place the Markdown one inside a div with “display: hidden.” I then have the ability to style each version of the title independently. 🙂

So, using an example from earlier in this thread, I can still italicize Iliad in the TOC if I wish, and just avoid any line breaks there. Meanwhile, I can stylize the in-text chapter title to my heart’s content, without affecting the TOC in any way. Perhaps even add a subtitle there, while displaying only the main title…

Replies: 8 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@artistofmind
Comment options

Comment options

You must be logged in to vote
1 reply
@bpj
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jgm
Comment options

Comment options

You must be logged in to vote
2 replies
@jgm
Comment options

@bpj
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by artistofmind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants