@@ -56,7 +56,7 @@ turn HTML to markdown at a higher-level (easier) abstraction.
5656## Install
5757
5858This package is [ ESM only] [ esm ] .
59- In Node.js (version 14.14+ and 16.0 +), install with [ npm] [ ] :
59+ In Node.js (version 16 +), install with [ npm] [ ] :
6060
6161``` sh
6262npm install hast-util-to-mdast
@@ -108,8 +108,9 @@ console.log(markdown)
108108
109109## API
110110
111- This package exports the identifiers [ ` defaultHandlers ` ] [ defaulthandlers ] ,
112- [ ` defaultNodeHandlers ` ] [ defaultnodehandlers ] , and [ ` toMdast ` ] [ tomdast ] .
111+ This package exports the identifiers [ ` defaultHandlers ` ] [ api-default-handlers ] ,
112+ [ ` defaultNodeHandlers ` ] [ api-default-node-handlers ] , and
113+ [ ` toMdast ` ] [ api-to-mdast ] .
113114There is no default export.
114115
115116### ` toMdast(tree[, options]) `
@@ -120,7 +121,7 @@ Transform hast to mdast.
120121
121122* ` tree ` ([ ` HastNode ` ] [ hast-node ] )
122123 — hast tree to transform
123- * ` options ` ([ ` Options ` ] [ options ] , optional)
124+ * ` options ` ([ ` Options ` ] [ api- options] , optional)
124125 — configuration
125126
126127###### Returns
@@ -131,21 +132,21 @@ mdast tree ([`MdastNode`][mdast-node]).
131132
132133Default handlers for elements (` Record<string, Handle> ` ).
133134
134- Each key is an element name, each value is a [ ` Handle ` ] [ handle ] .
135+ Each key is an element name, each value is a [ ` Handle ` ] [ api- handle] .
135136
136137### ` defaultNodeHandlers `
137138
138139Default handlers for nodes (` Record<string, NodeHandle> ` ).
139140
140- Each key is a node type, each value is a [ ` NodeHandle ` ] [ nodehandle ] .
141+ Each key is a node type, each value is a [ ` NodeHandle ` ] [ api-node-handle ] .
141142
142143### ` Handle `
143144
144145Handle a particular element (TypeScript type).
145146
146147###### Parameters
147148
148- * ` state ` ([ ` State ` ] [ state ] )
149+ * ` state ` ([ ` State ` ] [ api- state] )
149150 — info passed around about the current state
150151* ` element ` ([ ` Element ` ] [ element ] )
151152 — element to transform
@@ -154,15 +155,15 @@ Handle a particular element (TypeScript type).
154155
155156###### Returns
156157
157- mdast node or nodes (` MdastNode | Array< MdastNode> | undefined ` ).
158+ mdast node or nodes (` Array< MdastNode> | MdastNode | undefined` ).
158159
159160### ` NodeHandle `
160161
161162Handle a particular node (TypeScript type).
162163
163164###### Parameters
164165
165- * ` state ` ([ ` State ` ] [ state ] )
166+ * ` state ` ([ ` State ` ] [ api- state] )
166167 — info passed around about the current state
167168* ` node ` (` any ` )
168169 — node to transform
@@ -171,7 +172,7 @@ Handle a particular node (TypeScript type).
171172
172173###### Returns
173174
174- mdast node or nodes (` MdastNode | Array< MdastNode> | undefined ` ).
175+ mdast node or nodes (` Array< MdastNode> | MdastNode | undefined` ).
175176
176177### ` Options `
177178
@@ -213,7 +214,7 @@ guillemets, a fourth single, a fifth double again, etc.
213214
214215###### ` document `
215216
216- Whether the given tree represents a complete document (` boolean? ` , default:
217+ Whether the given tree represents a complete document (` boolean ` , default:
217218` undefined ` ).
218219
219220Applies when the ` tree ` is a ` root ` node.
@@ -228,15 +229,15 @@ Object mapping tag names to functions handling the corresponding elements
228229(` Record<string, Handle> ` ).
229230
230231Merged into the defaults.
231- See [ ` Handle ` ] [ handle ] .
232+ See [ ` Handle ` ] [ api- handle] .
232233
233234###### ` nodeHandlers `
234235
235236Object mapping node types to functions handling the corresponding nodes
236237(` Record<string, NodeHandle> ` ).
237238
238239Merged into the defaults.
239- See [ ` NodeHandle ` ] [ nodehandle ] .
240+ See [ ` NodeHandle ` ] [ api-node-handle ] .
240241
241242### ` State `
242243
@@ -246,7 +247,7 @@ Info passed around about the current state (TypeScript type).
246247
247248* ` patch ` (` (from: HastNode, to: MdastNode) => undefined ` )
248249 — copy a node’s positional info
249- * ` one ` (` (node: HastNode, parent: HastParent | undefined) => MdastNode | Array< MdastNode> | undefined ` )
250+ * ` one ` (` (node: HastNode, parent: HastParent | undefined) => Array< MdastNode> | MdastNode | undefined ` )
250251 — transform a hast node to mdast
251252* ` all ` (` (parent: HastParent) => Array<MdastContent> ` )
252253 — transform the children of a hast parent to mdast
@@ -256,14 +257,14 @@ Info passed around about the current state (TypeScript type).
256257 — turn arbitrary content into a list of a particular node type
257258* ` resolve ` (` (url: string | null | undefined) => string ` )
258259 — resolve a URL relative to a base
259- * ` options ` ([ ` Options ` ] [ options ] )
260+ * ` options ` ([ ` Options ` ] [ api- options] )
260261 — user configuration
261262* ` elementById ` (` Map<string, Element> ` )
262263 — elements by their ` id `
263264* ` handlers ` (` Record<string, Handle> ` )
264- — applied element handlers (see [ ` Handle ` ] [ handle ] )
265+ — applied element handlers (see [ ` Handle ` ] [ api- handle] )
265266* ` nodeHandlers ` (` Record<string, NodeHandle> ` )
266- — applied node handlers (see [ ` NodeHandle ` ] [ nodehandle ] )
267+ — applied node handlers (see [ ` NodeHandle ` ] [ api-node-handle ] )
267268* ` baseFound ` (` boolean ` )
268269 — whether a ` <base> ` element was seen
269270* ` frozenBaseUrl ` (` string | undefined ` )
@@ -331,8 +332,8 @@ This can be achieved with `example.js` like so:
331332
332333import fs from ' node:fs/promises'
333334import {fromHtml } from ' hast-util-from-html'
334- import {toMdast } from ' hast-util-to-mdast'
335335import {toHtml } from ' hast-util-to-html'
336+ import {toMdast } from ' hast-util-to-mdast'
336337import {toMarkdown } from ' mdast-util-to-markdown'
337338
338339const html = String (await fs .readFile (' example.html' ))
@@ -409,15 +410,20 @@ such as footnotes, frontmatter, or math.
409410## Types
410411
411412This package is fully typed with [ TypeScript] [ ] .
412- It exports the additional types [ ` Handle ` ] [ handle ] , [ ` NodeHandle ` ] [ nodehandle ] ,
413- [ ` Options ` ] [ options ] , and [ ` State ` ] [ state ] .
413+ It exports the additional types [ ` Handle ` ] [ api-handle ] ,
414+ [ ` NodeHandle ` ] [ api-node-handle ] ,
415+ [ ` Options ` ] [ api-options ] ,
416+ and [ ` State ` ] [ api-state ] .
414417
415418## Compatibility
416419
417- Projects maintained by the unified collective are compatible with all maintained
420+ Projects maintained by the unified collective are compatible with maintained
418421versions of Node.js.
419- As of now, that is Node.js 14.14+ and 16.0+.
420- Our projects sometimes work with older versions, but this is not guaranteed.
422+
423+ When we cut a new major release, we drop support for unmaintained versions of
424+ Node.
425+ This means we try to keep the current release line, ` hast-util-to-mdast@^9 ` ,
426+ compatible with Node.js 12.
421427
422428## Security
423429
@@ -458,9 +464,9 @@ abide by its terms.
458464
459465[ downloads ] : https://www.npmjs.com/package/hast-util-to-mdast
460466
461- [ size-badge ] : https://img.shields.io/bundlephobia/minzip/ hast-util-to-mdast.svg
467+ [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q= hast-util-to-mdast
462468
463- [ size ] : https://bundlephobia .com/result?p =hast-util-to-mdast
469+ [ size ] : https://bundlejs .com/?q =hast-util-to-mdast
464470
465471[ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
466472
@@ -516,16 +522,16 @@ abide by its terms.
516522
517523[ rehype-remark ] : https://github.com/rehypejs/rehype-remark
518524
519- [ defaulthandlers ] : #defaulthandlers
525+ [ api-default-handlers ] : #defaulthandlers
520526
521- [ defaultnodehandlers ] : #defaultnodehandlers
527+ [ api-default-node-handlers ] : #defaultnodehandlers
522528
523- [ tomdast ] : #tomdasttree-options
529+ [ api-to-mdast ] : #tomdasttree-options
524530
525- [ options ] : #options
531+ [ api- options] : #options
526532
527- [ state ] : #state
533+ [ api- state] : #state
528534
529- [ handle ] : #handle
535+ [ api- handle] : #handle
530536
531- [ nodehandle ] : #nodehandle
537+ [ api-node-handle ] : #nodehandle
0 commit comments