Skip to content

Commit ff73541

Browse files
readme and license
1 parent 72524b5 commit ff73541

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2016 Jonathan Haines <jonno.haines@gmail.com>
4+
5+
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
6+
7+
Permission is hereby granted, free of charge, to any person obtaining
8+
a copy of this software and associated documentation files (the
9+
'Software'), to deal in the Software without restriction, including
10+
without limitation the rights to use, copy, modify, merge, publish,
11+
distribute, sublicense, and/or sell copies of the Software, and to
12+
permit persons to whom the Software is furnished to do so, subject to
13+
the following conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,101 @@
1+
# mdast-util-toc [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status]
12

3+
Generate a Table of Contents from a [**mdast**][mdast] tree.
4+
5+
## Installation
6+
7+
[npm][]:
8+
9+
```bash
10+
npm install remark-toc
11+
```
12+
13+
**mdast-util-toc** is also available as an AMD, CommonJS, and globals
14+
module, [uncompressed and compressed][releases].
15+
16+
Dependencies:
17+
18+
```javascript
19+
var remark = require('remark');
20+
var toc = require('mdast-util-toc');
21+
```
22+
23+
Transform:
24+
25+
```javascript
26+
var file = remark().parse(([
27+
'# Alpha',
28+
'',
29+
'## Bravo',
30+
'',
31+
'### Charlie',
32+
'',
33+
'## Delta',
34+
''
35+
].join('\n'));
36+
```
37+
38+
Yields:
39+
40+
```markdown
41+
- [Alpha]
42+
43+
- [Bravo](#bravo)
44+
45+
- [Charlie](#charlie)
46+
47+
- [Delta](#delta)
48+
```
49+
50+
## API
51+
52+
### `toc(node[, options])`
53+
54+
Generate a Table of Contents from a Markdown document.
55+
56+
* Looks for the first heading containing `"Table of Contents"`, `"toc"`,
57+
or `table-of-contents` (case insensitive, supports alt/title attributes
58+
for links and images too);
59+
60+
* Removes all following contents until an equal or higher heading is found;
61+
62+
* Inserts a list representation of the hierarchy of following headings;
63+
64+
* Adds links to following headings, using the same slugs as GitHub.
65+
66+
#### `options`
67+
68+
* `heading` (`string?`)
69+
— Heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i');`
70+
71+
* `maxDepth` (`number?`, default: `6`)
72+
— Maximum heading depth to include in the table of contents,
73+
This is inclusive, thus, when set to `3`, level three headings,
74+
are included (those with three hashes, `###`);
75+
76+
* `tight` (`boolean?`, default: `false`)
77+
— Whether to compile list-items tightly.
78+
79+
## License
80+
81+
[MIT][license] © [Jonathan Haines][author]
82+
83+
<!-- Definitions -->
84+
85+
[build-badge]: https://img.shields.io/travis/BarryThePenguin/mdast-util-toc.svg
86+
87+
[build-status]: https://travis-ci.org/BarryThePenguin/mdast-util-toc
88+
89+
[coverage-badge]: https://img.shields.io/codecov/c/github/BarryThePenguin/mdast-util-toc.svg
90+
91+
[coverage-status]: https://codecov.io/github/BarryThePenguin/mdast-util-toc
92+
93+
[releases]: https://github.com/BarryThePenguin/mdast-util-toc/releases
94+
95+
[license]: LICENSE
96+
97+
[author]: http://barrythepenguin.github.io
98+
99+
[npm]: https://docs.npmjs.com/cli/install
100+
101+
[mdast]: https://github.com/wooorm/mdast

0 commit comments

Comments
 (0)