mdast-util-toc
Advanced tools
Comparing version 4.1.3 to 4.2.0
@@ -7,2 +7,3 @@ 'use strict' | ||
var contents = require('./contents') | ||
var toExpression = require('./to-expression') | ||
@@ -27,6 +28,1 @@ // Get a TOC representation of `node`. | ||
} | ||
// Transform a string into an applicable expression. | ||
function toExpression(value) { | ||
return new RegExp('^(' + value + ')$', 'i') | ||
} |
@@ -9,2 +9,3 @@ 'use strict' | ||
var slugs = require('github-slugger')() | ||
var toExpression = require('./to-expression') | ||
@@ -19,2 +20,3 @@ var heading = convert('heading') | ||
var maxDepth = settings.maxDepth || 6 | ||
var skip = settings.skip ? toExpression(settings.skip) : null | ||
var parents = convert(settings.parents || root) | ||
@@ -67,3 +69,8 @@ var map = [] | ||
if (!lookingForToc && value && child.depth <= maxDepth) { | ||
if ( | ||
!lookingForToc && | ||
value && | ||
child.depth <= maxDepth && | ||
(!skip || !skip.test(value)) | ||
) { | ||
map.push({ | ||
@@ -70,0 +77,0 @@ depth: child.depth, |
{ | ||
"name": "mdast-util-toc", | ||
"version": "4.1.3", | ||
"version": "4.2.0", | ||
"description": "Generate a Table of Contents (TOC) from a given Markdown file", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -96,2 +96,9 @@ # mdast-util-toc | ||
###### `options.skip` | ||
Headings to skip (`string`, optional), wrapped in | ||
`new RegExp('^(' + value + ')$', 'i')`. | ||
Any heading matching this expression will not be present in the table of | ||
contents. | ||
###### `options.tight` | ||
@@ -98,0 +105,0 @@ |
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
15506
8
237
222