Skip to content

Commit 6cf2256

Browse files
committed
add minDepth option
1 parent 455d638 commit 6cf2256

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/search.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
*
1919
* This is inclusive: when set to `3`, level three headings are included
2020
* (those with three hashes, `###`).
21+
* @property {Rank | null | undefined} [minDepth=6]
22+
* Minimum heading depth to include in the table of contents (default: `1`).
23+
*
24+
* This is inclusive: when set to `3`, level three headings are included
25+
* (those with three hashes, `###`).
2126
* @property {string | null | undefined} [skip]
2227
* Headings to skip, wrapped in `new RegExp('^(' + value + ')$', 'i')`
2328
* (default: `undefined`).
@@ -125,6 +130,7 @@ export function search(root, expression, settings) {
125130
// A heading after the closing (if we were looking for one).
126131
if (
127132
(endIndex || !expression) &&
133+
(!settings.minDepth || node.depth >= settings.minDepth) &&
128134
(!settings.maxDepth || node.depth <= settings.maxDepth) &&
129135
(!skip || !skip.test(value))
130136
) {

0 commit comments

Comments
 (0)