Hi, another great idea :-D I was working on something similar, but just piping the html through simple combination of grep+sed+awk to extract the id from all the header. I just test your script, but I found a small bug: the spaces in header are converted to hypen, but the markdown engine in nvalt (or the multimarkdown from macports I use) just delete the spaces. It results in wrong href in the table of contents! See an example at this gist. EDIT Just changing line 99 from
link = title.gsub(/[^ a-z]/i,'').gsub(/ +/,"-").downcase
to
link = title.gsub(/[^ a-z]/i,'').gsub(/ +/,"").downcase
Not really planning many new features for nvALT. Reading in Marked is way better than nvALT can aspire to, and there's a keyboard shortcut in nvALT now for opening the current file in Marked. You can also just drag your notes folder full of text files to Marked, and it will always preview the one you're currently editing.
Not a bug. That's the format that GitHub uses, and I specifically designed this to make life easier when using the main GitHub site and not the wiki or gh-pages.
On my local machine I have other solutions, most of them automatic. Marked for example, generates both a popup and embeddable TOC for my Markdown reading. http://marked2app.com
nvALT, on the other hand, doesn't have a built in solution, but you can inject JavaScript into the template to do it.
There are a dozen plugins that will do it for you. Just plug the CDN version of jQuery into the template.html file in ~/Library/Application Support/nvALT and add any necessary css to the custom.css file in there.
There's a token you can use when referencing any additional JS files in that folder: {%support%}. That will create an absolute reference to the Application Support path for you.
Thanks for the hints, my nvalt template at github already has jquery. I'm adapting this code, seems promising. If there is a #toc id in the documents, it appensd a contents list it on the fly.
Ok, I do added a small javascript fragment in my my nvalt template at github. Essentially, if you create an element with id='toc' the script attach to it all the document header with indentation proportional to the actual index to document base inde differenca : the base index is h2 tipically, but it could vary.