Why does this grunt plugin not exist yet? Perhaps because bitbucket has a [TOC] tag.
Look, this is generated by the plugin:
Table of Contents
- Getting Started
- The "doctoc" task
- Release History
Also, the repo of the doctoc script is: https://github.com/thlorenz/doctoc
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-doctoc --save-dev
The "doctoc" task
In your project's Gruntfile, add a section named
doctoc to the data object passed into
Point to a single file. It gets the doctoc treatment. This means, unless already added, the following tags will be prepended to your file:
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> **Table of Contents** ... <!-- END doctoc generated TOC please keep comment here to allow auto update -->
The toc will be between the tags. After re-running, the toc will be placed between the tags again. Copy the above one if you want.
Oh yeah, bitbucket currently (2014-07-25) shows html entities as strings. Enjoy the html tags.
"**Table of Contents**"
You can change the header with this. The doctoc script hardcoded prints out this default header, so this is the option
to swap that line. Oh yeah, the plugin just does str-replace of the first hit, so I recommend keeping your toc on top
of the file, or not using the exact string
"**Table of Contents**" in your md.
Default value: false
Outputs TOC in bitbucket format. In case you do not want the automatically generated [TOC] one, I guess. I swear, they should at least add that feature to the bitbucket markdown demo page.
Default value: true
By default, the doctoc script will add a message saying it is generated with DocToc. Screw that. So much free software on github that does without. Set it to false to make it show up again.
Assuming you have a
README.md file in your base directory, the default options should do well. Since it's a multitask,
you probably want to create an empty object regardless. Oh yeah, the default header is bold text, so...
suppose you want that to be another header:
If you want to use it on several files, for instance
./wiki/index.md, you can do:
Sure, add/fix whatever you want.