Nice,
I did something similar, but I want to have something integrated in nvalt.
I ended up with a small javascript fragment added to nvalt template.html that puts a TOC after the HTML is rendered.
When you insert a #TOC in a markdown document, you create an id="toc" in html, the script scan all the header in the document and put a TOC list there on the fly.
Cheers and thank for your inspiring work!!