Add function to generate TOC from document headings #474
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Adresses #344.
I separated this into two PRs. This one only adds the function to extract a table of contents out of a markdown document's header tags. The table of content only has two levels at most. By default h2 tags are used for top level headings and h3 for subheadings. This can be customized, and the idea is to allow users to choose the tags to be used as top level and sub headings from siteConfig. More info about that in the other PR.
Test Plan
This function is pretty self-contained and should work from anywhere. Document markdown in => table of contents out.
Related PRs
#475