Skip to content

Commit d21c50b

Browse files
committed
Add improved docs
1 parent 20891fa commit d21c50b

File tree

2 files changed

+57
-17
lines changed

2 files changed

+57
-17
lines changed

lib/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const inConstruct = 'phrasing'
2323
/** @type {Array<ConstructName>} */
2424
const notInConstruct = ['autolink', 'link', 'image', 'label']
2525

26+
// To do: next major: expose functions instead of extensions.
27+
2628
/**
2729
* Extension for `mdast-util-from-markdown` to enable GFM autolink literals.
2830
*

readme.md

+55-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
[mdast][] extensions to parse and serialize [GFM][] autolinks.
11+
[mdast][] extensions to parse and serialize [GFM][] autolink literals.
1212

1313
## Contents
1414

@@ -19,6 +19,8 @@
1919
* [API](#api)
2020
* [`gfmAutolinkLiteralFromMarkdown`](#gfmautolinkliteralfrommarkdown)
2121
* [`gfmAutolinkLiteralToMarkdown`](#gfmautolinkliteraltomarkdown)
22+
* [HTML](#html)
23+
* [Syntax](#syntax)
2224
* [Syntax tree](#syntax-tree)
2325
* [Types](#types)
2426
* [Compatibility](#compatibility)
@@ -28,12 +30,16 @@
2830

2931
## What is this?
3032

31-
This package contains extensions that add support for the autolink syntax
32-
enabled by GFM to [`mdast-util-from-markdown`][mdast-util-from-markdown] and
33-
[`mdast-util-to-markdown`][mdast-util-to-markdown].
33+
This package contains two extensions that add support for GFM autolink literals
34+
syntax in markdown to [mdast][].
35+
These extensions plug into
36+
[`mdast-util-from-markdown`][mdast-util-from-markdown] (to support parsing
37+
GFM autolinks in markdown into a syntax tree) and
38+
[`mdast-util-to-markdown`][mdast-util-to-markdown] (to support serializing
39+
GFM autolinks in syntax trees to markdown).
3440

3541
GitHub employs different algorithms to autolink: one at parse time and one at
36-
transform time (similar to how @mentions are done at transform time).
42+
transform time (similar to how `@mentions` are done at transform time).
3743
This difference can be observed because character references and escapes are
3844
handled differently.
3945
But also because issues/PRs/comments omit (perhaps by accident?) the second
@@ -47,22 +53,30 @@ perform the second algorithm, and as they are combined, both are done.
4753

4854
## When to use this
4955

50-
These tools are all rather low-level.
51-
In most cases, you’d want to use [`remark-gfm`][remark-gfm] with remark instead.
56+
You can use these extensions when you are working with
57+
`mdast-util-from-markdown` and `mdast-util-to-markdown` already.
58+
59+
When working with `mdast-util-from-markdown`, you must combine this package
60+
with
61+
[`micromark-extension-gfm-autolink-literal`][extension].
62+
63+
When you don’t need a syntax tree, you can use [`micromark`][micromark]
64+
directly with `micromark-extension-gfm-autolink-literal`.
5265

5366
When you are working with syntax trees and want all of GFM, use
5467
[`mdast-util-gfm`][mdast-util-gfm] instead.
5568

56-
When working with `mdast-util-from-markdown`, you must combine this package with
57-
[`micromark-extension-gfm-autolink-literal`][extension].
69+
All these packages are used [`remark-gfm`][remark-gfm], which
70+
focusses on making it easier to transform content by abstracting these
71+
internals away.
5872

5973
This utility does not handle how markdown is turned to HTML.
6074
That’s done by [`mdast-util-to-hast`][mdast-util-to-hast].
6175

6276
## Install
6377

6478
This package is [ESM only][esm].
65-
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
79+
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
6680

6781
```sh
6882
npm install mdast-util-gfm-autolink-literal
@@ -155,35 +169,47 @@ console.log(out)
155169

156170
## API
157171

158-
This package exports the identifiers `gfmAutolinkLiteralFromMarkdown` and
159-
`gfmAutolinkLiteralToMarkdown`.
172+
This package exports the identifiers
173+
[`gfmAutolinkLiteralFromMarkdown`][api-gfmautolinkliteralfrommarkdown] and
174+
[`gfmAutolinkLiteralToMarkdown`][api-gfmautolinkliteraltomarkdown].
160175
There is no default export.
161176

162177
### `gfmAutolinkLiteralFromMarkdown`
163178

164-
Extension for [`mdast-util-from-markdown`][mdast-util-from-markdown].
179+
Extension for [`mdast-util-from-markdown`][mdast-util-from-markdown] to enable
180+
GFM autolink literals ([`FromMarkdownExtension`][frommarkdownextension]).
165181

166182
### `gfmAutolinkLiteralToMarkdown`
167183

168-
Extension for [`mdast-util-to-markdown`][mdast-util-to-markdown].
184+
Extension for [`mdast-util-to-markdown`][mdast-util-to-markdown] to enable
185+
GFM autolink literals ([`ToMarkdownExtension`][tomarkdownextension]).
186+
187+
## HTML
188+
189+
This utility does not handle how markdown is turned to HTML.
190+
That’s done by [`mdast-util-to-hast`][mdast-util-to-hast].
191+
192+
## Syntax
193+
194+
See [Syntax in `micromark-extension-gfm-autolink-literal`][syntax].
169195

170196
## Syntax tree
171197

172198
There are no interfaces added to **[mdast][]** by this utility, as it reuses
173-
the existing [**Link**][dfn-link] interface.
199+
the existing **[Link][dfn-link]** interface.
174200

175201
## Types
176202

177203
This package is fully typed with [TypeScript][].
178204
It does not export additional types.
179205

180-
The `Link` node type is supported in `@types/mdast` by default.
206+
The `Link` type of the mdast nodes is exposed from `@types/mdast`.
181207

182208
## Compatibility
183209

184210
Projects maintained by the unified collective are compatible with all maintained
185211
versions of Node.js.
186-
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
212+
As of now, that is Node.js 14.14+ and 16.0+.
187213
Our projects sometimes work with older versions, but this is not guaranteed.
188214

189215
This plugin works with `mdast-util-from-markdown` version 1+ and
@@ -273,8 +299,20 @@ abide by its terms.
273299

274300
[remark-gfm]: https://github.com/remarkjs/remark-gfm
275301

302+
[micromark]: https://github.com/micromark/micromark
303+
276304
[extension]: https://github.com/micromark/micromark-extension-gfm-autolink-literal
277305

306+
[syntax]: https://github.com/micromark/micromark-extension-gfm-autolink-literal#syntax
307+
278308
[gfm]: https://github.github.com/gfm/
279309

280310
[dfn-link]: https://github.com/syntax-tree/mdast#link
311+
312+
[frommarkdownextension]: https://github.com/syntax-tree/mdast-util-from-markdown#extension
313+
314+
[tomarkdownextension]: https://github.com/syntax-tree/mdast-util-to-markdown#options
315+
316+
[api-gfmautolinkliteralfrommarkdown]: #gfmautolinkliteralfrommarkdown
317+
318+
[api-gfmautolinkliteraltomarkdown]: #gfmautolinkliteraltomarkdown

0 commit comments

Comments
 (0)