Forum Archive

Auto-generate table of contents

jeremyburton

Has anyone already created a workflow to auto-generate a hyperlinked table of contents in Editorial? My searches haven't unearthed anything. I'd like to be able to add a TOC to the top of longer Markdown docs. If no one has already done this, does anyone have any suggestions for how to go about this?

Loveless212

I have something similar to what you are asking about, mine though takes titles > creates file > than links it.

lrr

You can put [TOC] at the top of your document, and use a few lines of Python instead of Editorial's renderer. The included markdown module has a toc extension.

Or you could write a script to put an anchor tag next to each of your headings, and prepend a Markdown list to your document. This is worse in every way, but allows you to edit the TOC independent of the headings.

omz

I've made a little demo workflow using @lrr's approach:

http://www.editorial-workflows.com/workflow/5874785116487680/QxP96UHBH-o

If you use the dark theme, you might want to adjust the CSS colors in the Show HTML action.