New Advanced Table of Contents version #930
nevillepark
started this conversation in
See what's new
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, I've updated my Advanced Table of Contents extension.
The main differences between it and @annaesvensson's yellow-toc extension:
<ol>
) rather than an unordered list (<ul>
) with added numbering.This allows users to customize list numbering and markers with CSS, e. g. if they want to use bullets or letters instead of numbers, use different styles of markers for different levels, etc. Because it is properly semantic HTML, it also means it can be styled without requiring special classes for each level.
Why a rewrite was necessary
When I first made it, I actually was wrong about how HTML lists should be nested! Mine produced lists like this:
The right way (which it now does) is
This works far better for screen readers and text-only browsers, and means the CSS does not need as much customization if the theme has minimal CSS or uses a simple classless stylesheet.
Future things to work on
[atoc]
shortcode or the page's front matter.<h2>
to<h4>
, and it's not easy to work around this and still have properly nested lists. The way I did it produces unsightly gaps in the table of contents list. I'll see if there's a better way to do this. Some ways that have occurred to me are parsing the Markdown content instead, or creating a nested rather than flat array and somehow pruning empty array levels.If anyone has tips or suggestions, please let me know!
Beta Was this translation helpful? Give feedback.
All reactions