mdast-util-toc
Advanced tools
Comparing version 7.0.0 to 7.0.1
@@ -1,3 +0,4 @@ | ||
export {toc} from './lib/index.js' | ||
export type Options = import('./lib/index.js').Options | ||
export type Result = import('./lib/index.js').Result | ||
export { toc } from "./lib/index.js"; | ||
export type Options = import('./lib/index.js').Options; | ||
export type Result = import('./lib/index.js').Result; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,10 +7,7 @@ /** | ||
*/ | ||
export function contents( | ||
map: Array<SearchEntry>, | ||
settings: ContentsOptions | ||
): import('mdast').List | ||
export type List = import('mdast').List | ||
export type ListItem = import('mdast').ListItem | ||
export type PhrasingContent = import('mdast').PhrasingContent | ||
export type SearchEntry = import('./search.js').SearchEntry | ||
export function contents(map: Array<SearchEntry>, settings: ContentsOptions): import("mdast").List; | ||
export type List = import('mdast').List; | ||
export type ListItem = import('mdast').ListItem; | ||
export type PhrasingContent = import('mdast').PhrasingContent; | ||
export type SearchEntry = import('./search.js').SearchEntry; | ||
/** | ||
@@ -20,19 +17,20 @@ * Build configuration. | ||
export type ContentsOptions = { | ||
/** | ||
* Whether to compile list items tightly (default: `false`). | ||
*/ | ||
tight?: boolean | null | undefined | ||
/** | ||
* Whether to compile list items as an ordered list, otherwise they are | ||
* unordered (default: `false`). | ||
*/ | ||
ordered?: boolean | null | undefined | ||
/** | ||
* Add a prefix to links to headings in the table of contents (default: | ||
* `undefined`). | ||
* | ||
* Useful for example when later going from mdast to hast and sanitizing with | ||
* `hast-util-sanitize`. | ||
*/ | ||
prefix?: string | null | undefined | ||
} | ||
/** | ||
* Whether to compile list items tightly (default: `false`). | ||
*/ | ||
tight?: boolean | null | undefined; | ||
/** | ||
* Whether to compile list items as an ordered list, otherwise they are | ||
* unordered (default: `false`). | ||
*/ | ||
ordered?: boolean | null | undefined; | ||
/** | ||
* Add a prefix to links to headings in the table of contents (default: | ||
* `undefined`). | ||
* | ||
* Useful for example when later going from mdast to hast and sanitizing with | ||
* `hast-util-sanitize`. | ||
*/ | ||
prefix?: string | null | undefined; | ||
}; | ||
//# sourceMappingURL=contents.d.ts.map |
@@ -21,8 +21,8 @@ /** | ||
*/ | ||
export function toc(tree: Nodes, options?: Options | null | undefined): Result | ||
export type List = import('mdast').List | ||
export type Nodes = import('mdast').Nodes | ||
export type SearchOptions = import('./search.js').SearchOptions | ||
export type ContentsOptions = import('./contents.js').ContentsOptions | ||
export type Options = ContentsOptions & ExtraOptions & SearchOptions | ||
export function toc(tree: Nodes, options?: Options | null | undefined): Result; | ||
export type List = import('mdast').List; | ||
export type Nodes = import('mdast').Nodes; | ||
export type SearchOptions = import('./search.js').SearchOptions; | ||
export type ContentsOptions = import('./contents.js').ContentsOptions; | ||
export type Options = ContentsOptions & ExtraOptions & SearchOptions; | ||
/** | ||
@@ -32,8 +32,8 @@ * Extra configuration fields. | ||
export type ExtraOptions = { | ||
/** | ||
* Heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i')` | ||
* (default: `undefined`). | ||
*/ | ||
heading?: string | null | undefined | ||
} | ||
/** | ||
* Heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i')` | ||
* (default: `undefined`). | ||
*/ | ||
heading?: string | null | undefined; | ||
}; | ||
/** | ||
@@ -43,20 +43,21 @@ * Results. | ||
export type Result = { | ||
/** | ||
* Index of the node right after the table of contents heading, `-1` if no | ||
* heading was found, `undefined` if no `heading` was given. | ||
*/ | ||
index: number | undefined | ||
/** | ||
* Index of the first node after `heading` that is not part of its section, | ||
* `-1` if no heading was found, `undefined` if no `heading` was given, same | ||
* as `index` if there are no nodes between `heading` and the first heading | ||
* in the table of contents. | ||
*/ | ||
endIndex: number | undefined | ||
/** | ||
* List representing the generated table of contents, `undefined` if no table | ||
* of contents could be created, either because no heading was found or | ||
* because no following headings were found. | ||
*/ | ||
map: List | undefined | ||
} | ||
/** | ||
* Index of the node right after the table of contents heading, `-1` if no | ||
* heading was found, `undefined` if no `heading` was given. | ||
*/ | ||
index: number | undefined; | ||
/** | ||
* Index of the first node after `heading` that is not part of its section, | ||
* `-1` if no heading was found, `undefined` if no `heading` was given, same | ||
* as `index` if there are no nodes between `heading` and the first heading | ||
* in the table of contents. | ||
*/ | ||
endIndex: number | undefined; | ||
/** | ||
* List representing the generated table of contents, `undefined` if no table | ||
* of contents could be created, either because no heading was found or | ||
* because no following headings were found. | ||
*/ | ||
map: List | undefined; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -9,12 +9,8 @@ /** | ||
*/ | ||
export function search( | ||
root: Nodes, | ||
expression: RegExp | undefined, | ||
settings: SearchOptions | ||
): SearchResult | ||
export type Heading = import('mdast').Heading | ||
export type Nodes = import('mdast').Nodes | ||
export type PhrasingContent = import('mdast').PhrasingContent | ||
export type Test = import('unist-util-is').Test | ||
export type Rank = Heading['depth'] | ||
export function search(root: Nodes, expression: RegExp | undefined, settings: SearchOptions): SearchResult; | ||
export type Heading = import('mdast').Heading; | ||
export type Nodes = import('mdast').Nodes; | ||
export type PhrasingContent = import('mdast').PhrasingContent; | ||
export type Test = import('unist-util-is').Test; | ||
export type Rank = Heading['depth']; | ||
/** | ||
@@ -24,27 +20,27 @@ * Search configuration. | ||
export type SearchOptions = { | ||
/** | ||
* Maximum heading depth to include in the table of contents (default: `6`). | ||
* | ||
* This is inclusive: when set to `3`, level three headings are included | ||
* (those with three hashes, `###`). | ||
*/ | ||
maxDepth?: Rank | null | undefined | ||
/** | ||
* Headings to skip, wrapped in `new RegExp('^(' + value + ')$', 'i')` | ||
* (default: `undefined`). | ||
* | ||
* Any heading matching this expression will not be present in the table of | ||
* contents. | ||
*/ | ||
skip?: string | null | undefined | ||
/** | ||
* Allow headings to be children of certain node types (default: the to `toc` | ||
* given `tree`, to only allow top-level headings) (default: | ||
* `d => d === tree`). | ||
* | ||
* Internally, uses `unist-util-is` to check, so `parents` can be any | ||
* `is`-compatible test. | ||
*/ | ||
parents?: Test | ||
} | ||
/** | ||
* Maximum heading depth to include in the table of contents (default: `6`). | ||
* | ||
* This is inclusive: when set to `3`, level three headings are included | ||
* (those with three hashes, `###`). | ||
*/ | ||
maxDepth?: Rank | null | undefined; | ||
/** | ||
* Headings to skip, wrapped in `new RegExp('^(' + value + ')$', 'i')` | ||
* (default: `undefined`). | ||
* | ||
* Any heading matching this expression will not be present in the table of | ||
* contents. | ||
*/ | ||
skip?: string | null | undefined; | ||
/** | ||
* Allow headings to be children of certain node types (default: the to `toc` | ||
* given `tree`, to only allow top-level headings) (default: | ||
* `d => d === tree`). | ||
* | ||
* Internally, uses `unist-util-is` to check, so `parents` can be any | ||
* `is`-compatible test. | ||
*/ | ||
parents?: Test; | ||
}; | ||
/** | ||
@@ -54,15 +50,15 @@ * Entry. | ||
export type SearchEntry = { | ||
/** | ||
* ID of entry. | ||
*/ | ||
id: string | ||
/** | ||
* Contents of entry. | ||
*/ | ||
children: Array<PhrasingContent> | ||
/** | ||
* Rank of entry. | ||
*/ | ||
depth: Rank | ||
} | ||
/** | ||
* ID of entry. | ||
*/ | ||
id: string; | ||
/** | ||
* Contents of entry. | ||
*/ | ||
children: Array<PhrasingContent>; | ||
/** | ||
* Rank of entry. | ||
*/ | ||
depth: Rank; | ||
}; | ||
/** | ||
@@ -72,14 +68,15 @@ * Results. | ||
export type SearchResult = { | ||
/** | ||
* Where the contents section starts, if looking for a heading. | ||
*/ | ||
index: number | ||
/** | ||
* Where the contents section ends, if looking for a heading. | ||
*/ | ||
endIndex: number | ||
/** | ||
* List of entries. | ||
*/ | ||
map: Array<SearchEntry> | ||
} | ||
/** | ||
* Where the contents section starts, if looking for a heading. | ||
*/ | ||
index: number; | ||
/** | ||
* Where the contents section ends, if looking for a heading. | ||
*/ | ||
endIndex: number; | ||
/** | ||
* List of entries. | ||
*/ | ||
map: Array<SearchEntry>; | ||
}; | ||
//# sourceMappingURL=search.d.ts.map |
@@ -7,2 +7,3 @@ /** | ||
*/ | ||
export function toExpression(value: string): RegExp | ||
export function toExpression(value: string): RegExp; | ||
//# sourceMappingURL=to-expression.d.ts.map |
{ | ||
"name": "mdast-util-toc", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "mdast utility to generate a table of contents from a tree", | ||
@@ -33,2 +33,3 @@ "license": "MIT", | ||
"lib/", | ||
"index.d.ts.map", | ||
"index.d.ts", | ||
@@ -40,3 +41,3 @@ "index.js" | ||
"@ungap/structured-clone": "^1.0.0", | ||
"@types/ungap__structured-clone": "^0.3.0", | ||
"@types/ungap__structured-clone": "^1.0.0", | ||
"github-slugger": "^2.0.0", | ||
@@ -49,12 +50,12 @@ "mdast-util-to-string": "^4.0.0", | ||
"@types/node": "^20.0.0", | ||
"c8": "^8.0.0", | ||
"mdast-util-from-markdown": "^1.0.0", | ||
"mdast-util-gfm": "^2.0.0", | ||
"micromark-extension-gfm": "^2.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^11.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"c8": "^9.0.0", | ||
"mdast-util-from-markdown": "^2.0.0", | ||
"mdast-util-gfm": "^3.0.0", | ||
"micromark-extension-gfm": "^3.0.0", | ||
"prettier": "^3.0.0", | ||
"remark-cli": "^12.0.0", | ||
"remark-preset-wooorm": "^10.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^5.0.0", | ||
"xo": "^0.54.0" | ||
"xo": "^0.58.0" | ||
}, | ||
@@ -64,3 +65,3 @@ "scripts": { | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix", | ||
"test-api": "node --conditions development test/index.js", | ||
@@ -98,4 +99,7 @@ "test-coverage": "c8 --100 --reporter lcov npm run test-api", | ||
], | ||
"prettier": true | ||
"prettier": true, | ||
"rules": { | ||
"unicorn/prefer-at": "off" | ||
} | ||
} | ||
} |
116
readme.md
@@ -15,16 +15,16 @@ # mdast-util-toc | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`toc(tree[, options])`](#toctree-options) | ||
* [`Options`](#options) | ||
* [`Result`](#result) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Related](#related) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`toc(tree[, options])`](#toctree-options) | ||
* [`Options`](#options) | ||
* [`Result`](#result) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Related](#related) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
@@ -123,6 +123,6 @@ ## What is this? | ||
* `tree` ([`Node`][node]) | ||
— tree to search and generate from | ||
* `options` ([`Options`][api-options], optional) | ||
— configuration | ||
* `tree` ([`Node`][node]) | ||
— tree to search and generate from | ||
* `options` ([`Options`][api-options], optional) | ||
— configuration | ||
@@ -139,24 +139,24 @@ ###### Returns | ||
* `heading` (`string`, optional) | ||
— heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i')` | ||
* `maxDepth` (`number`, default: `6`) | ||
— maximum heading depth to include in the table of contents. | ||
This is inclusive: when set to `3`, level three headings are included | ||
(those with three hashes, `###`) | ||
* `skip` (`string`, optional) | ||
— headings to skip, wrapped in `new RegExp('^(' + value + ')$', 'i')`. | ||
Any heading matching this expression will not be present in the table of | ||
contents | ||
* `parents` ([`Test`][test], default: `tree`) | ||
— allow headings to be children of certain node types. | ||
Can by any [`unist-util-is`][is] compatible test | ||
* `tight` (`boolean`, default: `false`) | ||
— whether to compile list items tightly | ||
* `ordered` (`boolean`, default: `false`) | ||
— whether to compile list items as an ordered list, otherwise they are | ||
unordered | ||
* `prefix` (`string`, optional) | ||
— add a prefix to links to headings in the table of contents. | ||
Useful for example when later going from mdast to hast and sanitizing with | ||
`hast-util-sanitize`. | ||
* `heading` (`string`, optional) | ||
— heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i')` | ||
* `maxDepth` (`number`, default: `6`) | ||
— maximum heading depth to include in the table of contents. | ||
This is inclusive: when set to `3`, level three headings are included | ||
(those with three hashes, `###`) | ||
* `skip` (`string`, optional) | ||
— headings to skip, wrapped in `new RegExp('^(' + value + ')$', 'i')`. | ||
Any heading matching this expression will not be present in the table of | ||
contents | ||
* `parents` ([`Test`][test], default: `tree`) | ||
— allow headings to be children of certain node types. | ||
Can by any [`unist-util-is`][is] compatible test | ||
* `tight` (`boolean`, default: `false`) | ||
— whether to compile list items tightly | ||
* `ordered` (`boolean`, default: `false`) | ||
— whether to compile list items as an ordered list, otherwise they are | ||
unordered | ||
* `prefix` (`string`, optional) | ||
— add a prefix to links to headings in the table of contents. | ||
Useful for example when later going from mdast to hast and sanitizing with | ||
`hast-util-sanitize`. | ||
@@ -169,14 +169,14 @@ ### `Result` | ||
* `index` (`number` or `undefined`) | ||
— index of the node right after the table of contents heading, `-1` if no | ||
heading was found, `undefined` if no `heading` was given | ||
* `endIndex` (`number` or `undefined`) | ||
— index of the first node after `heading` that is not part of its section, | ||
`-1` if no heading was found, `undefined` if no `heading` was given, same as | ||
`index` if there are no nodes between `heading` and the first heading in | ||
the table of contents | ||
* `map` ([`List`][list] or `undefined`) | ||
— list representing the generated table of contents, `undefined` if no | ||
table of contents could be created, either because no heading was found or | ||
because no following headings were found | ||
* `index` (`number` or `undefined`) | ||
— index of the node right after the table of contents heading, `-1` if no | ||
heading was found, `undefined` if no `heading` was given | ||
* `endIndex` (`number` or `undefined`) | ||
— index of the first node after `heading` that is not part of its section, | ||
`-1` if no heading was found, `undefined` if no `heading` was given, same as | ||
`index` if there are no nodes between `heading` and the first heading in | ||
the table of contents | ||
* `map` ([`List`][list] or `undefined`) | ||
— list representing the generated table of contents, `undefined` if no | ||
table of contents could be created, either because no heading was found or | ||
because no following headings were found | ||
@@ -231,8 +231,8 @@ ## Types | ||
* [`github-slugger`](https://github.com/Flet/github-slugger) | ||
— generate a slug just like GitHub does | ||
* [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit) | ||
— visit nodes | ||
* [`unist-util-visit-parents`](https://github.com/syntax-tree/unist-util-visit-parents) | ||
— like `visit`, but with a stack of parents | ||
* [`github-slugger`](https://github.com/Flet/github-slugger) | ||
— generate a slug just like GitHub does | ||
* [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit) | ||
— visit nodes | ||
* [`unist-util-visit-parents`](https://github.com/syntax-tree/unist-util-visit-parents) | ||
— like `visit`, but with a stack of parents | ||
@@ -239,0 +239,0 @@ ## Contribute |
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
31065
18
541
+ Added@types/ungap__structured-clone@1.2.0(transitive)
- Removed@types/ungap__structured-clone@0.3.3(transitive)