Open danyspin97 opened 6 years ago
I also think this might be a better as a post-level parameter.
Strange, it should look like this. I'll investigate this.
It should be fixed now.
Let me explain better how it works now. It gets all the line that are formatted as h[1-4]
and put them in the same level in the table of contents, that is enabled by adding toc: true
in the post parameters and it is disabled by default.
The original snippet tried to understand the level number and insert relative nested lists. The wanted result was something like this:
If you prefer to have the table of contents formatted as this last example, I don't mind working to achieve this last example, but I would prefer to have it simple as it is currently.
Hm, it seems kind of strange to flatten the table of contents, at least without offering both as an option. By default, I'd think it'd be better to retain information about the structure of the post.
But I don't want to make this too much of a burden either. We could merge this, and allow it to be enabled with a flag like flat-toc
and then possibly add a hierarchical toc in the future.
Improved! Now the table of contents respect the paragraph level, as the original post. I needed to add some css to remove blank lines between the levels. It also reads all the section from h2
to h4
. I've a left the button "Table of Contents" as the original gist.
Is this what it's supposed to look like?
I think the concept is useful, but there should be some styling before this is merged. Any thoughts?
Thanks for your work in initiating this! 🎈