remark-toc
Advanced tools
Comparing version 3.0.0-alpha.1 to 3.0.0-alpha.2
{ | ||
"name": "remark-toc", | ||
"version": "3.0.0-alpha.1", | ||
"version": "3.0.0-alpha.2", | ||
"description": "Generate a Table of Contents (TOC) for Markdown files", | ||
@@ -23,4 +23,14 @@ "license": "MIT", | ||
}, | ||
"repository": "wooorm/remark-toc", | ||
"author": "Titus Wormer <tituswormer@gmail.com>", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/remark-toc.git" | ||
}, | ||
"bugs": "https://github.com/wooorm/remark-toc/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
], | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"files": [ | ||
@@ -40,3 +50,3 @@ "index.js" | ||
"remark-lint": "^2.0.0", | ||
"remark-usage": "^2.0.0", | ||
"remark-usage": "^2.1.0", | ||
"remark-validate-links": "^2.0.0", | ||
@@ -43,0 +53,0 @@ "tape": "^4.0.0" |
118
readme.md
@@ -1,9 +0,8 @@ | ||
# remark-toc [![Build Status](https://img.shields.io/travis/wooorm/remark-toc.svg)](https://travis-ci.org/wooorm/remark-toc) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/remark-toc.svg)](https://codecov.io/github/wooorm/remark-toc) | ||
# remark-toc [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
Generate a Table of Contents (TOC) for [Markdown](http://daringfireball.net/projects/markdown/syntax) | ||
files with [remark](https://github.com/wooorm/remark). | ||
Generate a Table of Contents in [**remark**][remark]. | ||
## Installation | ||
[npm](https://docs.npmjs.com/cli/install): | ||
[npm][npm-install]: | ||
@@ -14,49 +13,49 @@ ```bash | ||
**remark-toc** is also available for [duo](http://duojs.org/#getting-started), | ||
and as an AMD, CommonJS, and globals module, [uncompressed and | ||
compressed](https://github.com/wooorm/remark-toc/releases). | ||
**remark-toc** is also available as an AMD, CommonJS, and globals | ||
module, [uncompressed and compressed][releases]. | ||
## Table of Contents | ||
* [Usage](#usage) | ||
* [API](#api) | ||
* [remark.use(toc, options)](#remarkusetoc-options) | ||
* [License](#license) | ||
## Usage | ||
Require/read dependencies: | ||
Dependencies: | ||
```javascript | ||
var remark = require('remark'); | ||
var toc = require('remark-toc'); | ||
var fs = require('fs'); | ||
var remark = require('remark').use(toc); | ||
var readme = fs.readFileSync('readme.md', 'utf-8'); | ||
``` | ||
Parse markdown (this TOC is the 7th child). | ||
Process: | ||
```javascript | ||
var contents = remark.run(remark.parse(readme)).children[7]; | ||
var doc = remark().use(toc).process([ | ||
'# Alpha', | ||
'', | ||
'## Table of Contents', | ||
'', | ||
'## Bravo', | ||
'', | ||
'### Charlie', | ||
'', | ||
'## Delta', | ||
'' | ||
].join('\n')); | ||
``` | ||
Stringify: | ||
```javascript | ||
var doc = remark.stringify(contents); | ||
``` | ||
Yields: | ||
```markdown | ||
- [Usage](#usage) | ||
# Alpha | ||
- [API](#api) | ||
## Table of Contents | ||
- [remark.use(toc, options)](#remarkusetoc-options) | ||
- [Bravo](#bravo) | ||
- [License](#license) | ||
- [Charlie](#charlie) | ||
- [Delta](#delta) | ||
## Bravo | ||
### Charlie | ||
## Delta | ||
``` | ||
@@ -66,5 +65,5 @@ | ||
### [remark](https://github.com/wooorm/remark#api).[use](https://github.com/wooorm/remark#remarkuseplugin-options)(toc, options) | ||
### `remark.use(toc[, options])` | ||
Adds a [Table of Contents](#table-of-contents) to a Markdown document. | ||
Add a Table of Contents to a Markdown document. | ||
@@ -81,29 +80,42 @@ * Looks for the first heading containing `"Table of Contents"`, `"toc"`, | ||
**Signatures** | ||
**Options** (`Object`, optional): | ||
* `remark.use(toc, options?)`. | ||
* `slug` | ||
— Passed to [`remark-slug`][remark-slug]; | ||
**Parameters** | ||
* `heading` (`string?`, default: `"toc|table[ -]of[ -]contents?"`) | ||
— Heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i');`; | ||
* `toc` — This plugin; | ||
* `maxDepth` (`number?`, default: `6`) | ||
— Maximum heading depth to include in the table of contents, | ||
This is inclusive, thus, when set to `3`, level three headings, | ||
are included (those with three hashes, `###`); | ||
* `options` (`Object?`) — Settings: | ||
* `tight` (`boolean?`, default: `false`) | ||
— Whether to compile list-items tightly. | ||
* `slug` — | ||
Passed to [`remark-slug`](https://github.com/wooorm/remark-slug) | ||
## License | ||
* `heading` (`string?`, default: `"toc|table[ -]of[ -]contents?"`) | ||
— Heading to look for, wrapped in | ||
`new RegExp('^(' + value + ')$', 'i');`. | ||
[MIT][license] © [Titus Wormer][author] | ||
* `maxDepth` (`number?`, default: `6`) | ||
— Maximum heading depth to include in the table of contents, | ||
This is inclusive, thus, when set to `3`, level three headings, | ||
are included (those with three hashes, `###`). | ||
<!-- Definitions --> | ||
* `tight` (`boolean?`, default: `false`) | ||
— Whether to compile list-items tightly. | ||
[travis-badge]: https://img.shields.io/travis/wooorm/remark-toc.svg | ||
## License | ||
[travis]: https://travis-ci.org/wooorm/remark-toc | ||
[MIT](LICENSE) © [Titus Wormer](http://wooorm.com) | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/remark-toc.svg | ||
[codecov]: https://codecov.io/github/wooorm/remark-toc | ||
[npm-install]: https://docs.npmjs.com/cli/install | ||
[releases]: https://github.com/wooorm/remark-toc/releases | ||
[license]: LICENSE | ||
[author]: http://wooorm.com | ||
[remark]: https://github.com/wooorm/remark | ||
[remark-slug]: https://github.com/wooorm/remark-slug |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
119
0
18360