Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonschlinkert/gulp-markdown-toc
Gulp plugin for markdown-toc. Generate a markdown table of contents for one or more markdown files, and an optional index for multiple files.
https://github.com/jonschlinkert/gulp-markdown-toc
gulp gulpplugin markdown md table-of-contents toc
Last synced: 3 months ago
JSON representation
Gulp plugin for markdown-toc. Generate a markdown table of contents for one or more markdown files, and an optional index for multiple files.
- Host: GitHub
- URL: https://github.com/jonschlinkert/gulp-markdown-toc
- Owner: jonschlinkert
- License: mit
- Created: 2017-02-20T01:57:29.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-08T18:55:15.000Z (over 7 years ago)
- Last Synced: 2024-10-04T18:50:51.557Z (4 months ago)
- Topics: gulp, gulpplugin, markdown, md, table-of-contents, toc
- Language: JavaScript
- Size: 11.7 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-markdown-toc [![NPM version](https://img.shields.io/npm/v/gulp-markdown-toc.svg?style=flat)](https://www.npmjs.com/package/gulp-markdown-toc) [![NPM monthly downloads](https://img.shields.io/npm/dm/gulp-markdown-toc.svg?style=flat)](https://npmjs.org/package/gulp-markdown-toc) [![NPM total downloads](https://img.shields.io/npm/dt/gulp-markdown-toc.svg?style=flat)](https://npmjs.org/package/gulp-markdown-toc) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/gulp-markdown-toc.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/gulp-markdown-toc)
> Gulp plugin for markdown-toc. Generate a markdown table of contents for one or more markdown files, and an optional index for multiple files.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save gulp-markdown-toc
```## Usage
```js
var gulp = require('gulp');
var toc = require('gulp-markdown-toc');gulp.task('toc', function() {
return gulp.src('*.md')
.pipe(toc())
.pipe(gulp.dest('.'));
});
```**Heads up!**
Add the following to markdown file where you want a Table of Contents to be injected:
```
```
## Options
In addition to the following plugin options, all [markdown-toc](https://github.com/jonschlinkert/markdown-toc) options are supported as well. See that library for additional details.
### options.index
**Type:** `{Boolean|String|Function}`
**Default:** `undefined`
Generate a Table of Contents index file. _If `options.index` is left undefined, an index file will not be generated._
```js
// generates a file named `toc.md`
toc({index: true})// specify the name of the index file
toc({index: 'foo.md'})// customize the destination and file path of the index file
toc({
index: function(file) {
file.basename = 'whatever.md';
return 'blah';
}
})
```### options.filterFiles
**Type:** `{Function}`
**Default:** `undefined`
Filter the files to be included in the TOC index.
```js
toc({
filter: function(file) {
return file.relative !== 'foo.md';
}
})
```### options.sortFiles
**Type:** `{Function}`
**Default:** `undefined`
Pass a compare function for sorting the files to be included in the TOC index.
```js
toc({
sort: function(fileA, fileB) {
// fileA and fileB are vinyl files
return fileA.relative < fileB.relative;
}
})
```### options.headingName
```
## [headingName](#headingLink)
```**Type:** `{Function}`
**Default:** `undefined`
Customize heading names.
```js
toc({
headingName: function(name) {
// do stuff to name
return name;
}
})
```### options.headingLink
```
## [headingName](#headingLink)
```**Type:** `{Function}`
**Default:** `undefined`
Customize heading links.
```js
toc({
headingLink: function(link) {
// do stuff to link
return link;
}
})
```## About
### Related projects
* [gulp-format-md](https://www.npmjs.com/package/gulp-format-md): Gulp plugin for beautifying markdown using pretty-remarkable. | [homepage](https://github.com/jonschlinkert/gulp-format-md "Gulp plugin for beautifying markdown using pretty-remarkable.")
* [markdown-toc](https://www.npmjs.com/package/markdown-toc): Generate a markdown TOC (table of contents) with Remarkable. | [homepage](https://github.com/jonschlinkert/markdown-toc "Generate a markdown TOC (table of contents) with Remarkable.")
* [remarkable](https://www.npmjs.com/package/remarkable): Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in… [more](https://github.com/jonschlinkert/remarkable) | [homepage](https://github.com/jonschlinkert/remarkable "Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in one.")### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 08, 2017._