Best practise to build a ToC #649
-
Hi, I'm wondering what is the best way to build a table of contents for a page.
The first one seems a better practise to me, since it separates concerns, while the latter seems more efficient, since there is no need to go through the document again: when a heading is rendered, I know it's a heading, I can handle it too and add it to the ToC (which would be injected in the What do you think? I'm thinking of a third method, but it requires features the library currently does not offer: events triggered by parsers and renderers. In my case, I've overridden the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Currently, I think walking the AST is probably the best option. I'm definitely interested in expanding the usage of events in this library - if you'd be open to sharing your ideas that would help me better understand how to best implement that :) |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer. I'll open a new issue about events in the next few days. |
Beta Was this translation helpful? Give feedback.
-
For anyone who comes across this question - we do have a Table of Contents extension now! |
Beta Was this translation helpful? Give feedback.
For anyone who comes across this question - we do have a Table of Contents extension now!