|
18 | 18 | * [Use](#use) |
19 | 19 | * [API](#api) |
20 | 20 | * [`headingStyle(node[, relative])`](#headingstylenode-relative) |
| 21 | + * [`Style`](#style) |
21 | 22 | * [Types](#types) |
22 | 23 | * [Compatibility](#compatibility) |
23 | 24 | * [Security](#security) |
@@ -45,7 +46,7 @@ It’s used in [`remark-lint`][remark-lint]. |
45 | 46 | ## Install |
46 | 47 |
|
47 | 48 | This package is [ESM only][esm]. |
48 | | -In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: |
| 49 | +In Node.js (version 14.14+ and 16.0+), install with [npm][]: |
49 | 50 |
|
50 | 51 | ```sh |
51 | 52 | npm install mdast-util-heading-style |
@@ -82,31 +83,48 @@ headingStyle(fromMarkdown('### ATX').children[0], 'setext') // => 'setext' |
82 | 83 |
|
83 | 84 | ## API |
84 | 85 |
|
85 | | -This package exports the identifier `headingStyle`. |
| 86 | +This package exports the identifier [`headingStyle`][api-headingstyle]. |
86 | 87 | There is no default export. |
87 | 88 |
|
88 | 89 | ### `headingStyle(node[, relative])` |
89 | 90 |
|
90 | | -Get the heading style of a node ([`Node`][node]), optionally `relative` to |
91 | | -a preferred style (`'atx'`, `'atx-closed'`, `'setext'`, optional). |
92 | | -This is because ATX headings with a depth of three or more could be considered |
93 | | -setext. |
| 91 | +Get the heading style of a heading, optionally `relative` to a preferred |
| 92 | +style. |
| 93 | + |
| 94 | +This is because ATX headings with a depth of three or more could be |
| 95 | +considered setext. |
| 96 | + |
| 97 | +###### Parameters |
| 98 | + |
| 99 | +* `node` ([`Heading`][heading]) |
| 100 | + — heading node to check |
| 101 | +* `style` ([`Style`][api-style], optional) |
| 102 | + — relative style |
94 | 103 |
|
95 | 104 | ###### Returns |
96 | 105 |
|
97 | | -Style (`'atx'`, `'atx-closed'`, or `'setext'`). |
98 | | -When an ambiguous heading is found, either `relative` or `null` is returned. |
| 106 | +Style ([`Style`][api-style]) if it can be inferred, `null` otherwise. |
| 107 | + |
| 108 | +### `Style` |
| 109 | + |
| 110 | +Style of heading (TypeScript type). |
| 111 | + |
| 112 | +###### Type |
| 113 | + |
| 114 | +```ts |
| 115 | +type Style = 'atx' | 'atx-closed' | 'setext' |
| 116 | +``` |
99 | 117 |
|
100 | 118 | ## Types |
101 | 119 |
|
102 | 120 | This package is fully typed with [TypeScript][]. |
103 | | -It exports the type `Style`. |
| 121 | +It exports the additional type [`Style`][api-style]. |
104 | 122 |
|
105 | 123 | ## Compatibility |
106 | 124 |
|
107 | 125 | Projects maintained by the unified collective are compatible with all maintained |
108 | 126 | versions of Node.js. |
109 | | -As of now, that is Node.js 12.20+, 14.14+, and 16.0+. |
| 127 | +As of now, that is Node.js 14.14+ and 16.0+. |
110 | 128 | Our projects sometimes work with older versions, but this is not guaranteed. |
111 | 129 |
|
112 | 130 | ## Security |
@@ -185,10 +203,14 @@ abide by its terms. |
185 | 203 |
|
186 | 204 | [mdast]: https://github.com/syntax-tree/mdast |
187 | 205 |
|
188 | | -[node]: https://github.com/syntax-tree/unist#node |
| 206 | +[heading]: https://github.com/syntax-tree/mdast#heading |
189 | 207 |
|
190 | 208 | [xss]: https://en.wikipedia.org/wiki/Cross-site_scripting |
191 | 209 |
|
192 | 210 | [hast]: https://github.com/syntax-tree/hast |
193 | 211 |
|
194 | 212 | [remark-lint]: https://github.com/remarkjs/remark-lint |
| 213 | +
|
| 214 | +[api-headingstyle]: #headingstylenode-relative |
| 215 | +
|
| 216 | +[api-style]: #style |
0 commit comments