Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonschlinkert/gulp-html-toc

Gulp plugin for html-toc, for generating a HTML table of contents.
https://github.com/jonschlinkert/gulp-html-toc

cheerio gulp gulpplugin html html-toc table-of-contents toc

Last synced: 4 months ago
JSON representation

Gulp plugin for html-toc, for generating a HTML table of contents.

Awesome Lists containing this project

README

        

# gulp-html-toc [![NPM version](https://img.shields.io/npm/v/gulp-html-toc.svg?style=flat)](https://www.npmjs.com/package/gulp-html-toc) [![NPM monthly downloads](https://img.shields.io/npm/dm/gulp-html-toc.svg?style=flat)](https://npmjs.org/package/gulp-html-toc) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/gulp-html-toc.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/gulp-html-toc)

> Gulp plugin for html-toc, for generating a HTML table of contents.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save gulp-html-toc
```

Install with [yarn](https://yarnpkg.com):

```sh
$ yarn add gulp-html-toc
```

## Usage

```js
var toc = require('gulp-html-toc');

gulp.task('toc', function() {
return gulp.src('foo/*.html')
.pipe(toc())
.pipe(gulp.dest('bar'));
});
```

## Options

### options.id

**Type**: `string`

**Default**: `#toc` (usage: `

`)

Specify the id for where the table of contents should be injected.

**Example**

```js
toc({id: '#navigation'});
```

In your HTML, add the following:

```html


```

### options.anchors

**Type**: `boolean`

**Default**: `undefined`

Set to `false` to disable anchors.

**Example**

```js
toc({anchors: false});
```

### options.anchorTemplate

Customize the template for creating anchors.

**Type**: `function`

**Default**

```html




```

**Example**

```js
toc({
anchorTemplate: function(id) {
return ``;
}
});
```

### options.selectors

Heading selectors to use for generating the table of contents.

**Type**: `string`

**Default**: `h1,h2`

**Example**

Generate a table of contents for all headings h1-h4.

```js
toc({selectors: 'h1,h2,h3,h4'});
```

## About

### Related projects

* [gulp-htmlmin](https://www.npmjs.com/package/gulp-htmlmin): gulp plugin to minify HTML. | [homepage](https://github.com/jonschlinkert/gulp-htmlmin#readme "gulp plugin to minify HTML.")
* [gulp-prettify](https://www.npmjs.com/package/gulp-prettify): Prettify, format, beautify HTML. | [homepage](https://github.com/jonschlinkert/gulp-prettify "Prettify, format, beautify HTML.")
* [html-toc](https://www.npmjs.com/package/html-toc): Generate a HTML table of contents using cheerio. | [homepage](https://github.com/jonschlinkert/html-toc "Generate a HTML table of contents using cheerio.")

### 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.5.0, on April 17, 2017._