[Feature request] TOC as a clickable sidebar
Thanks for making this awesome Quick Look plugin!
Is there a way to add a table of contents as a sidebar in one of the next releases? I think it would be really useful esp. for long documents.
Is this planned?
not soon, sorry
@sbarex — totally understand it's not a priority right now, but since I wanted it for my own long documents, I went ahead and built it out as a complete, self-contained feature. It's done and ready to open as a PR whenever you'd like a look.
It's a pure render-layer feature: no new dependency and no changes to the cmark extensions. In getCompleteHTML it turns the already-rendered headings into a sticky, clickable sidebar next to the content:
- It mints its own unique, clean anchors, so duplicate headings and emoji headings each scroll to the right place — and it works independently of the Heads anchor extension.
- Smooth scroll, percentage width, and it collapses to full-width content on narrow previews so it never crowds the text.
- Pure HTML/CSS (no JS), so it renders and scrolls in the data-based Quick Look preview — verified in real Finder Quick Look, not just the in-app preview.
- Gated behind a new "Table of contents" option in Preferences → Options (plus a
--table-of-contentsCLI flag), off by default. The Preferences checkbox is fully wired — no loose ends.
Screenshots — the sidebar rendering in Finder Quick Look, and the new setting:
| TOC sidebar (Finder Quick Look) | Preferences option |
|---|---|
![]() |
![]() |
To try it: enable Table of contents in Preferences → Options, then open the example files I added under examples/ — toc-anchor-test.md for a normal long document, and the toc-edge-cases/ folder for the gnarly stuff (duplicate / emoji / Unicode / setext headings, fake headings inside code blocks, 40+ headings, very long titles, …).
Branch (no PR yet): https://github.com/soreavis/QLMarkdown/tree/feature/toc-sidebar
It's ready to go whenever you want it, and just as easy to leave parked if it's not something you want in the app. And if there's anything you'd want added or done differently — behaviour, defaults, styling, where the toggle lives — just say the word and I'm happy to change it.
@sbarex — totally understand it's not a priority right now, but since I wanted it for my own long documents, I went ahead and built it out as a complete, self-contained feature. It's done and ready to open as a PR whenever you'd like a look.
TOC sidebar (Finder Quick Look) Preferences option
![]()
Wow, @soreavis Love this! You rock! 🤘 Would love to see it in the app. The only improvement I would make, but that's personal preference, it is to have the sidebar (TOC) (customizable) in a different color, maybe like so.
@zenminimalist I wouldn't go that route, as the main markdown area is already visually separated from the rest of the Preview window. It would divide the screen into 2 significant areas, and for short TOCs, it wouldn't make much sense. I tested all edge cases, too, and this solution was the best one in terms of usability and not cluttering your view with unnecessary stuff.

