Skip to content

Commit 6fbf704

Browse files
committed
Change to include Contents headings by default
1 parent 64f5cd9 commit 6fbf704

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {toc} from 'mdast-util-toc'
2121
export default function remarkToc(options) {
2222
const settings = {
2323
...options,
24-
heading: (options && options.heading) || 'toc|table[ -]of[ -]contents?',
24+
heading: (options && options.heading) || '(table[ -]of[ -])?contents?|toc',
2525
tight: options && typeof options.tight === 'boolean' ? options.tight : true
2626
}
2727

readme.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ import remarkToc from 'remark-toc'
122122
import {read} from 'to-vfile'
123123

124124
const file = await remark()
125-
.use(remarkToc, {heading: 'contents'})
125+
.use(remarkToc)
126126
.process(await read('example.md'))
127127

128128
console.error(String(file))
@@ -193,7 +193,7 @@ Configuration (TypeScript type).
193193

194194
###### Fields
195195

196-
* `heading` (`string`, default: `'toc|table[ -]of[ -]contents?'`)
196+
* `heading` (`string`, default: `'(table[ -]of[ -])?contents?|toc'`)
197197
— heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i')`
198198
* `maxDepth` (`number`, default: `6`)
199199
— max heading depth to include in the table of contents; this is inclusive:
@@ -262,9 +262,7 @@ so:
262262
1. [History](#history)
263263

264264
1. [Discovery](#discovery)
265-
266265
2. [Name and symbol](#name-and-symbol)
267-
268266
3. [Planet X disproved](#planet-x-disproved)
269267

270268
2. [Orbit](#orbit)

test/fixtures/contents/input.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Alpha
2+
3+
## Contents
4+
5+
# Bravo

test/fixtures/contents/output.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Alpha
2+
3+
## Contents
4+
5+
* [Bravo](#bravo)
6+
7+
# Bravo

0 commit comments

Comments
 (0)