markdown-toc icon indicating copy to clipboard operation
markdown-toc copied to clipboard

Custom toc and tocstop

Open ghost opened this issue 7 years ago • 6 comments

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!

ghost avatar Dec 12 '17 19:12 ghost

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.

doowb avatar Dec 13 '17 17:12 doowb

Cool! I'll see if I can grok the code and get something working.

ghost avatar Dec 13 '17 21:12 ghost

I think I've got it close to working, just had a quick question. Where is options.regex being passed to insert()?

ghost avatar Dec 14 '17 00:12 ghost

insert is used in the cli, but most of the time, it's just using the default from here

doowb avatar Dec 14 '17 00:12 doowb

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).

koppor avatar Feb 04 '18 21:02 koppor

Would absolutely be good to have!

slavaaaaaaaaaa avatar Aug 09 '18 21:08 slavaaaaaaaaaa