markdown-toc
markdown-toc copied to clipboard
Custom toc and tocstop
I'd like to use this tool with Bitbucket, but Bitbucket automatically escapes the <!--toc--> and <!--tocstop--> tags.
I wrote a quick and dirty npm package called markdown-bucketoc that uses pure markdown comments ([comment]: <> (toc) and [comment]: <> (tocstop)) to anchor the toc, but I figured it might not be a bad idea to add the feature to this package. I was thinking two additional API options and command line switches to add a custom start and stop would be a great idea.
If you'd to accept PRs for this, I'd be more than willing to work on it!
A PR would be great!
There are already options available for specifying the regex used and the open and close tags. But modifications are necessary to work with completely custom regex/delimiters like you're suggesting. There's also the inject-snippet library that allows custom options for almost anything. I think a small updated here would be necessary to customize the creation of the close delimiter.
Feel free to ask questions here or we can continue the discussion on code specifics in the PRs.
Cool! I'll see if I can grok the code and get something working.
I think I've got it close to working, just had a quick question. Where is options.regex being passed to insert()?
Highly appreciated. This would add support for atom's markdown-toc:
<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
- [Contents](#contents)
...
<!-- /TOC -->
And also for atom-mdtoc package:
<!-- MDTOC maxdepth:6 firsth1:0 numbering:1 flatten:0 bullets:1 updateOnSave:0 -->
...
<!-- /MDTOC -->
Surely, it would be nice if the text "TOC" could be restored. So I would not have to install Atom for updating TOCs of other projects (such as certain awesome-lists).
Would absolutely be good to have!