Skip to content

Commit 2f48939

Browse files
Add docs to TOCOptions
1 parent 45e0e4c commit 2f48939

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

types/index.d.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,53 @@ import {Test} from 'unist-util-is'
77
declare namespace mdastUtilToc {
88

99
interface TOCOptions {
10+
/**
11+
* Heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i')`.
12+
*/
1013
heading?: string
14+
15+
/**
16+
* Maximum heading depth to include in the table of contents (default: `6`),
17+
* This is inclusive: when set to `3`,
18+
* level three headings are included (those with three hashes, `###`).
19+
*/
1120
maxDepth?: Heading['depth']
21+
22+
/**
23+
* Headings to skip, wrapped in `new RegExp('^(' + value + ')$', 'i')`.
24+
* Any heading matching this expression will not be present in the table of contents.
25+
*/
1226
skip?: string
27+
28+
/**
29+
* Whether to compile list-items tightly (default: `false`).
30+
*/
1331
tight?: boolean
32+
33+
/**
34+
* Add a prefix to links to headings in the table of contents (default: null).
35+
* Useful for example when later going from mdast to hast and sanitizing with `hast-util-sanitize`.
36+
*/
1437
prefix?: string
38+
39+
/**
40+
* Allows headings to be children of certain node types
41+
* (default: the to `toc` given `tree`, to only allow top-level headings).
42+
* Internally, uses `unist-util-is` to check, so `parents` can be any `is`-compatible test.
43+
*
44+
* For example, this would allow headings under either `root` or `blockquote` to be used:
45+
*
46+
* ```ts
47+
* toc(tree, {parents: ['root', 'blockquote']})
48+
* ```
49+
*/
1550
parents?: Test<Node> | Array<Test<Node>>
1651
}
1752

1853
interface TOCResult {
19-
index?: number
20-
endIndex?: number
21-
map?: List
54+
index: number | null
55+
endIndex: number | null
56+
map: List | null
2257
}
2358
}
2459

0 commit comments

Comments
 (0)