Awesome
markdown-it-toc
Table of contents plugin for markdown-it.
Install
bower install markdown-it-toc
Use (in browser)
var md = window.markdownit();
md = md.use(window.markdownitTOC);
console.log(md.render('# test\n\n[TOC]\n\n## something'));