<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">I'm using Markdown in an app and would like to provide support for including a table of contents. </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Any suggestions for a syntax? Has anyone done this before?</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">My first thoughts are:</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">1. Have a special header item (using markdown extra's header syntax), e.g.</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">generate-contents: yes</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">2. Have a special xml tag with optional alternative text inside</span>, e.g.<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><contents></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">1. First thingy</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">2. Second thingy</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">3. Other stuff</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></contents></span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">3. Detect that a set of list items matches the first few headers. E.g. if the document has headers</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># Monkeys</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">## </span><span style="font-family: courier new,monospace;">Chimps</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">## Humans</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">## Proboscis monkeys</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">## Other monkeys</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">## Do Lemur's count?</span><br style="font-family: courier new,monospace;">
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Then a list that ran:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">1. Monkeys</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 1. Chimps<br> 2. Humans</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><br>Would be detected as the start of a contents list, and the other entries would automatically be added to it. This seems the nicest approach in some respects, but also the one likely to cause confusion and annoyance.<br>
<br>Your thoughts?<br> - Daniel<br><br style="font-family: courier new,monospace;">