
Security News
OpenClaw Skill Marketplace Emerges as Active Malware Vector
Security researchers report widespread abuse of OpenClaw skills to deliver info-stealing malware, exposing a new supply chain risk as agent ecosystems scale.
Verb generator that adds middleware for creating and injecting a table of contents into a markdown document.
Verb generator that adds middleware for creating and injecting a table of contents into a markdown document.
Install with npm:
$ npm install verb-toc --save
HEADS UP!!!
This only works with Verb v0.9.0 and higher! (also works with assemble).
var toc = require('verb-toc');
Basic example
In your verbfile.js:
module.exports = function(verb) {
verb.extendWith(require('verb-toc'));
// do stuff, render templates, write files
};
Add a <!-- toc --> HTML comment to any markdown document where you want a table of contents to be injected. For the TOC middleware to run, you'll need to either call the postLayout and preWrite middleware handlers yourself, or follow the example below.
Middleware
The main export is a function that when invoked with an instance of verb will automatically register two middleware functions:
.postLayout (createToc) middleware that creates the table of contents after a layout has been applied.preWrite (injectToc) middleware that injects the table of contents back into the document after all other plugins have run.Both middleware functions are also exposed as properties on module.exports, so you can try other stages if you want. Be warned that there are pros and cons to most middleware stages, in my own experience these stages work really well and seem to result in the fewest unwanted side-effects.
If you want to completely customize how the TOC is injected, you can listen for the toc event.
Params
file Exposes the vinyl file being renderedExample
verb.on('toc', function(file, next) {
// do stuff to `file.contents`, then call next
next();
});
Register the middleware
In your verbfile.js:
module.exports = function(verb) {
verb.extendWith(require('verb-toc'));
// use any template engine, but you must call `.renderFile`
// (below) to trigger the necessary middleware stages
verb.engine('*', require('engine-base'));
// example task
verb.task('docs', function(cb) {
return verb.src('docs/*.md', { cwd: __dirname })
.pipe(app.renderFile('*'))
.pipe(verb.dest('dist'));
});
verb.task('default', ['docs']);
};
(In v0.9.0 and higher, verbfiles that export a function are recognized by verb as "generators", allowing them to be locally or globally installed, and composed with other generators. You can alternatively export an instance of verb, but it's not as fun...)
Enable or disable Table of Contents rendering, or pass options on the verb config object in package.json.
Example
{
"name": "my-project",
"verb": {
"toc": true
}
}
Disable or enable TOC rendering from the command line.
Enable
Enable the table of contents for the current build:
$ verb --toc
Disable
Disable the table of contents for the current build:
$ verb --toc=false
Persist TOC settings for a project to the verb config object in package.json:
Enable
Enable the table of contents for a project:
$ verb --config=toc
Disable
Disable the table of contents for a project:
$ verb --config=toc:false
Persist TOC settings to be used as global:
Enable
Enable the table of contents for a project:
$ verb --global=toc
# or
$ verb -g=toc
Disable
Disable the table of contents for a project:
$ verb --global=toc:false
# or
$ verb -g=toc:false
You might also be interested in these projects:
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with verb:
$ npm install verb && npm run docs
Or, if verb is installed globally:
$ verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on May 07, 2016.
FAQs
Verb plugin that adds middleware for creating and injecting a table of contents into a markdown document.
We found that verb-toc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Security researchers report widespread abuse of OpenClaw skills to deliver info-stealing malware, exposing a new supply chain risk as agent ecosystems scale.

Security News
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.