19
19
* [ API] ( #api )
20
20
* [ ` gfmFootnoteFromMarkdown() ` ] ( #gfmfootnotefrommarkdown )
21
21
* [ ` gfmFootnoteToMarkdown() ` ] ( #gfmfootnotetomarkdown )
22
+ * [ HTML] ( #html )
23
+ * [ Syntax] ( #syntax )
22
24
* [ Syntax tree] ( #syntax-tree )
23
25
* [ Nodes] ( #nodes )
24
26
* [ Content model] ( #content-model )
30
32
31
33
## What is this?
32
34
33
- This package contains extensions that add support for the footnote syntax
34
- enabled by GFM to [ ` mdast-util-from-markdown ` ] [ mdast-util-from-markdown ] and
35
- [ ` mdast-util-to-markdown ` ] [ mdast-util-to-markdown ] .
35
+ This package contains two extensions that add support for GFM footnote syntax
36
+ in markdown to [ mdast] [ ] .
37
+ These extensions plug into
38
+ [ ` mdast-util-from-markdown ` ] [ mdast-util-from-markdown ] (to support parsing
39
+ footnotes in markdown into a syntax tree) and
40
+ [ ` mdast-util-to-markdown ` ] [ mdast-util-to-markdown ] (to support serializing
41
+ footnotes in syntax trees to markdown).
36
42
37
43
GFM footnotes were [ announced September 30, 2021] [ post ] but are not specified.
38
44
Their implementation on github.com is currently buggy.
39
45
The bugs have been reported on [ ` cmark-gfm ` ] [ cmark-gfm ] .
40
46
41
47
## When to use this
42
48
43
- These tools are all rather low-level.
44
- In most cases, you’d want to use [ ` remark-gfm ` ] [ remark-gfm ] with remark instead.
49
+ You can use these extensions when you are working with
50
+ ` mdast-util-from-markdown ` and ` mdast-util-to-markdown ` already.
51
+
52
+ When working with ` mdast-util-from-markdown ` , you must combine this package
53
+ with [ ` micromark-extension-gfm-footnote ` ] [ micromark-extension-gfm-footnote ] .
54
+
55
+ When you don’t need a syntax tree, you can use [ ` micromark ` ] [ micromark ]
56
+ directly with ` micromark-extension-gfm-footnote ` .
45
57
46
58
When you are working with syntax trees and want all of GFM, use
47
59
[ ` mdast-util-gfm ` ] [ mdast-util-gfm ] instead.
48
60
49
- When working with ` mdast-util-from-markdown ` , you must combine this package with
50
- [ ` micromark-extension-gfm-footnote ` ] [ extension ] .
61
+ All these packages are used [ ` remark-gfm ` ] [ remark-gfm ] , which
62
+ focusses on making it easier to transform content by abstracting these
63
+ internals away.
51
64
52
65
This utility does not handle how markdown is turned to HTML.
53
66
That’s done by [ ` mdast-util-to-hast ` ] [ mdast-util-to-hast ] .
@@ -56,7 +69,7 @@ If your content is not in English, you should configure that utility.
56
69
## Install
57
70
58
71
This package is [ ESM only] [ esm ] .
59
- In Node.js (version 12.20+, 14.14+, or 16.0+), install with [ npm] [ ] :
72
+ In Node.js (version 14.14+ and 16.0+), install with [ npm] [ ] :
60
73
61
74
``` sh
62
75
npm install mdast-util-gfm-footnote
@@ -142,19 +155,42 @@ Hi\![^1]
142
155
143
156
## API
144
157
145
- This package exports the identifiers ` gfmFootnoteFromMarkdown ` and
146
- ` gfmFootnoteToMarkdown ` .
158
+ This package exports the identifiers
159
+ [ ` gfmFootnoteFromMarkdown ` ] [ api-gfmfootnotefrommarkdown ] and
160
+ [ ` gfmFootnoteToMarkdown ` ] [ api-gfmfootnotetomarkdown ] .
147
161
There is no default export.
148
162
149
163
### ` gfmFootnoteFromMarkdown() `
150
164
151
- Function that can be called to get an extension for
152
- [ ` mdast-util-from-markdown ` ] [ mdast-util-from-markdown ] .
165
+ Create an extension for
166
+ [ ` mdast-util-from-markdown ` ] [ mdast-util-from-markdown ]
167
+ to enable GFM footnotes in markdown.
168
+
169
+ ###### Returns
170
+
171
+ Extension for ` mdast-util-from-markdown `
172
+ ([ ` FromMarkdownExtension ` ] [ frommarkdownextension ] ).
153
173
154
174
### ` gfmFootnoteToMarkdown() `
155
175
156
- Function that can be called to get an extension for
157
- [ ` mdast-util-to-markdown ` ] [ mdast-util-to-markdown ] .
176
+ Create an extension for
177
+ [ ` mdast-util-to-markdown ` ] [ mdast-util-to-markdown ]
178
+ to enable GFM footnotes in markdown.
179
+
180
+ ###### Returns
181
+
182
+ Extension for ` mdast-util-to-markdown `
183
+ ([ ` ToMarkdownExtension ` ] [ tomarkdownextension ] ).
184
+
185
+ ## HTML
186
+
187
+ This utility does not handle how markdown is turned to HTML.
188
+ That’s done by [ ` mdast-util-to-hast ` ] [ mdast-util-to-hast ] .
189
+ If your content is not in English, you should configure that utility.
190
+
191
+ ## Syntax
192
+
193
+ See [ Syntax in ` micromark-extension-frontmatter ` ] [ syntax ] .
158
194
159
195
## Syntax tree
160
196
@@ -166,25 +202,25 @@ The following interfaces are added to **[mdast][]** by this utility.
166
202
167
203
``` idl
168
204
interface FootnoteDefinition <: Parent {
169
- type: " footnoteDefinition"
205
+ type: ' footnoteDefinition'
170
206
children: [FlowContent]
171
207
}
172
208
173
209
FootnoteDefinition includes Association
174
210
```
175
211
176
- ** FootnoteDefinition** ([ ** Parent** ] [ dfn-parent ] ) represents content relating
212
+ ** FootnoteDefinition** (** [ Parent] [ dfn-parent ] ** ) represents content relating
177
213
to the document that is outside its flow.
178
214
179
- ** FootnoteDefinition** can be used where [ ** flow** ] [ dfn-flow-content ] content is
180
- expected.
181
- Its content model is also [ ** flow** ] [ dfn-flow-content ] content.
215
+ ** FootnoteDefinition** can be used where ** [ flow] [ dfn-flow-content ] ** content
216
+ is expected.
217
+ Its content model is also ** [ flow] [ dfn-flow-content ] ** content.
182
218
183
219
** FootnoteDefinition** includes the mixin
184
- [ ** Association** ] [ dfn-mxn-association ] .
220
+ ** [ Association] [ dfn-mxn-association ] ** .
185
221
186
222
** FootnoteDefinition** should be associated with
187
- [ ** FootnoteReferences** ] [ dfn-footnote-reference ] .
223
+ ** [ FootnoteReferences] [ dfn-footnote-reference ] ** .
188
224
189
225
For example, the following markdown:
190
226
@@ -210,23 +246,23 @@ Yields:
210
246
211
247
``` idl
212
248
interface FootnoteReference <: Node {
213
- type: " footnoteReference"
249
+ type: ' footnoteReference'
214
250
}
215
251
216
252
FootnoteReference includes Association
217
253
```
218
254
219
- ** FootnoteReference** ([ ** Node** ] [ dfn-node ] ) represents a marker through
255
+ ** FootnoteReference** (** [ Node] [ dfn-node ] ** ) represents a marker through
220
256
association.
221
257
222
258
** FootnoteReference** can be used where
223
- [ ** static phrasing** ] [ dfn-static-phrasing-content ] content is expected.
259
+ ** [ static phrasing] [ dfn-static-phrasing-content ] ** content is expected.
224
260
It has no content model.
225
261
226
- ** FootnoteReference** includes the mixin [ ** Association** ] [ dfn-mxn-association ] .
262
+ ** FootnoteReference** includes the mixin ** [ Association] [ dfn-mxn-association ] ** .
227
263
228
264
** FootnoteReference** should be associated with a
229
- [ ** FootnoteDefinition** ] [ dfn-footnote-definition ] .
265
+ ** [ FootnoteDefinition] [ dfn-footnote-definition ] ** .
230
266
231
267
For example, the following markdown:
232
268
@@ -255,36 +291,35 @@ type FlowContentGfm = FootnoteDefinition | FlowContent
255
291
#### ` StaticPhrasingContent ` (GFM footnotes)
256
292
257
293
``` idl
258
- type StaticPhrasingContentGfm =
259
- FootnoteReference | StaticPhrasingContent
294
+ type StaticPhrasingContentGfm = FootnoteReference | StaticPhrasingContent
260
295
```
261
296
262
297
## Types
263
298
264
299
This package is fully typed with [ TypeScript] [ ] .
265
300
It does not export additional types.
266
301
267
- The ` FootnoteDefinition ` and ` FootnoteReference ` node types are supported in
268
- ` @types/mdast ` by default .
302
+ The ` FootnoteDefinition ` and ` FootnoteReference ` types of the mdast nodes are
303
+ exposed from ` @types/mdast ` .
269
304
270
305
## Compatibility
271
306
272
307
Projects maintained by the unified collective are compatible with all maintained
273
308
versions of Node.js.
274
- As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
309
+ As of now, that is Node.js 14.14+ and 16.0+.
275
310
Our projects sometimes work with older versions, but this is not guaranteed.
276
311
277
312
This plugin works with ` mdast-util-from-markdown ` version 1+ and
278
313
` mdast-util-to-markdown ` version 1+.
279
314
280
315
## Related
281
316
282
- * [ ` remarkjs/ remark-gfm` ] [ remark-gfm ]
317
+ * [ ` remark-gfm ` ] [ remark-gfm ]
283
318
— remark plugin to support GFM
284
- * [ ` syntax-tree/ mdast-util-gfm` ] [ mdast-util-gfm ]
319
+ * [ ` mdast-util-gfm ` ] [ mdast-util-gfm ]
285
320
— same but all of GFM (autolink literals, footnotes, strikethrough, tables,
286
321
tasklists)
287
- * [ ` micromark/micromark -extension-gfm-footnote ` ] [ extension ]
322
+ * [ ` micromark-extension-gfm-footnote ` ] [ micromark- extension-gfm-footnote ]
288
323
— micromark extension to parse GFM footnotes
289
324
290
325
## Contribute
@@ -355,7 +390,11 @@ abide by its terms.
355
390
356
391
[ remark-gfm ] : https://github.com/remarkjs/remark-gfm
357
392
358
- [ extension ] : https://github.com/micromark/micromark-extension-gfm-footnote
393
+ [ micromark ] : https://github.com/micromark/micromark
394
+
395
+ [ micromark-extension-gfm-footnote ] : https://github.com/micromark/micromark-extension-gfm-footnote
396
+
397
+ [ syntax ] : https://github.com/micromark/micromark-extension-gfm-footnote#syntax
359
398
360
399
[ gfm ] : https://github.github.com/gfm/
361
400
@@ -375,10 +414,18 @@ abide by its terms.
375
414
376
415
[ dfn-node ] : https://github.com/syntax-tree/unist#node
377
416
417
+ [ frommarkdownextension ] : https://github.com/syntax-tree/mdast-util-from-markdown#extension
418
+
419
+ [ tomarkdownextension ] : https://github.com/syntax-tree/mdast-util-to-markdown#options
420
+
378
421
[ dfn-flow-content ] : #flowcontent-gfm-footnotes
379
422
380
423
[ dfn-static-phrasing-content ] : #staticphrasingcontent-gfm-footnotes
381
424
382
425
[ dfn-footnote-reference ] : #footnotereference
383
426
384
427
[ dfn-footnote-definition ] : #footnotedefinition
428
+
429
+ [ api-gfmfootnotefrommarkdown ] : #gfmfootnotefrommarkdown
430
+
431
+ [ api-gfmfootnotetomarkdown ] : #gfmfootnotetomarkdown
0 commit comments