Skip to content

Commit 0af1dcb

Browse files
committed
Refactor docs
1 parent a4f9d57 commit 0af1dcb

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

readme.md

+21-18
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`toHast(tree[, options])`](#tohasttree-options)
2120
* [`defaultHandlers`](#defaulthandlers)
21+
* [`toHast(tree[, options])`](#tohasttree-options)
2222
* [`Handler`](#handler)
2323
* [`Handlers`](#handlers)
2424
* [`Options`](#options)
@@ -62,7 +62,7 @@ turn markdown to HTML at a higher-level (easier) abstraction.
6262
## Install
6363

6464
This package is [ESM only][esm].
65-
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
65+
In Node.js (version 16+), install with [npm][]:
6666

6767
```sh
6868
npm install mdast-util-to-hast
@@ -94,9 +94,9 @@ Say we have the following `example.md`:
9494

9595
```js
9696
import {fs} from 'node:fs/promises'
97+
import {toHtml} from 'hast-util-to-html'
9798
import {fromMarkdown} from 'mdast-util-from-markdown'
9899
import {toHast} from 'mdast-util-to-hast'
99-
import {toHtml} from 'hast-util-to-html'
100100

101101
const markdown = String(await fs.readFile('example.md'))
102102
const mdast = fromMarkdown(markdown)
@@ -118,6 +118,10 @@ This package exports the identifiers [`defaultHandlers`][api-default-handlers]
118118
and [`toHast`][api-to-hast].
119119
There is no default export.
120120

121+
### `defaultHandlers`
122+
123+
Default handlers for nodes ([`Handlers`][api-handlers]).
124+
121125
### `toHast(tree[, options])`
122126

123127
Transform mdast to hast.
@@ -200,10 +204,6 @@ The default behavior for unknown nodes is:
200204

201205
This behavior can be changed by passing an `unknownHandler`.
202206

203-
### `defaultHandlers`
204-
205-
Default handlers for nodes ([`Handlers`][api-handlers]).
206-
207207
### `Handler`
208208

209209
Handle a node (TypeScript).
@@ -346,11 +346,11 @@ The following example passes `allowDangerousHtml` to this utility
346346
(`hast-util-sanitize`):
347347

348348
```js
349-
import {fromMarkdown} from 'mdast-util-from-markdown'
350-
import {toHast} from 'mdast-util-to-hast'
351349
import {raw} from 'hast-util-raw'
352350
import {sanitize} from 'hast-util-sanitize'
353351
import {toHtml} from 'hast-util-to-html'
352+
import {fromMarkdown} from 'mdast-util-from-markdown'
353+
import {toHast} from 'mdast-util-to-hast'
354354

355355
const markdown = 'It <i>works</i>! <img onerror="alert(1)">'
356356
const mdast = fromMarkdown(markdown)
@@ -380,11 +380,11 @@ should translate the labels associated with them.
380380
Let’s first set the stage:
381381

382382
```js
383-
import {fromMarkdown} from 'mdast-util-from-markdown'
383+
import {toHtml} from 'hast-util-to-html'
384384
import {gfm} from 'micromark-extension-gfm'
385+
import {fromMarkdown} from 'mdast-util-from-markdown'
385386
import {gfmFromMarkdown} from 'mdast-util-gfm'
386387
import {toHast} from 'mdast-util-to-hast'
387-
import {toHtml} from 'hast-util-to-html'
388388

389389
const markdown = 'Bonjour[^1]\n\n[^1]: Monde!'
390390
const mdast = fromMarkdown(markdown, {
@@ -457,8 +457,8 @@ For example, when we represent a mark element in markdown and want to turn it
457457
into a `<mark>` element in HTML, we can use a handler:
458458

459459
```js
460-
import {toHast} from 'mdast-util-to-hast'
461460
import {toHtml} from 'hast-util-to-html'
461+
import {toHast} from 'mdast-util-to-hast'
462462

463463
const mdast = {
464464
type: 'paragraph',
@@ -484,8 +484,8 @@ console.log(toHtml(hast))
484484
We can do the same through certain fields on nodes:
485485

486486
```js
487-
import {toHast} from 'mdast-util-to-hast'
488487
import {toHtml} from 'hast-util-to-html'
488+
import {toHast} from 'mdast-util-to-hast'
489489

490490
const mdast = {
491491
type: 'paragraph',
@@ -1365,10 +1365,13 @@ visit(tree, function (node) {
13651365

13661366
## Compatibility
13671367

1368-
Projects maintained by the unified collective are compatible with all maintained
1368+
Projects maintained by the unified collective are compatible with maintained
13691369
versions of Node.js.
1370-
As of now, that is Node.js 14.14+ and 16.0+.
1371-
Our projects sometimes work with older versions, but this is not guaranteed.
1370+
1371+
When we cut a new major release, we drop support for unmaintained versions of
1372+
Node.
1373+
This means we try to keep the current release line, `mdast-util-to-hast@^12`,
1374+
compatible with Node.js 12.
13721375

13731376
## Security
13741377

@@ -1476,9 +1479,9 @@ abide by its terms.
14761479

14771480
[downloads]: https://www.npmjs.com/package/mdast-util-to-hast
14781481

1479-
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-to-hast.svg
1482+
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-to-hast
14801483

1481-
[size]: https://bundlephobia.com/result?p=mdast-util-to-hast
1484+
[size]: https://bundlejs.com/?q=mdast-util-to-hast
14821485

14831486
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
14841487

0 commit comments

Comments
 (0)