Automatic Table of Contents generation

I think a first pass could just hardcode this. I would look at what Google Docs does as a model. They include H1-H6 in the ToC.

The workflow would be something like:

  1. Write a post with headers
  2. Click a button in the “gear icon dropdown” to generate a ToC
  3. ToC is an outline with links to the headings, indented by heading level
  4. ToC is just markdown inserted into the composer that you can edit/delete
  5. Clicking the “generate ToC” buttons would not replace the existing ToC, but instead, just insert a new one.*

* this is different than what Google Docs does, but probably a lot easier and completely acceptable in my opinion.

7 Likes