8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ mdast] [ ] extensions to parse and serialize [ MDX] [ ] expressions (` {Math.PI} ` ).
11
+ [ mdast] [ github-mdast ] extensions to parse and serialize [ MDX] [ mdxjs ]
12
+ expressions (` {Math.PI} ` ).
12
13
13
14
## Contents
14
15
37
38
## What is this?
38
39
39
40
This package contains two extensions that add support for MDX expression syntax
40
- in markdown to [ mdast] [ ] .
41
+ in markdown to [ mdast] [ github-mdast ] .
41
42
These extensions plug into
42
- [ ` mdast-util-from-markdown ` ] [ mdast-util-from-markdown ] (to support parsing
43
- expressions in markdown into a syntax tree) and
44
- [ ` mdast-util-to-markdown ` ] [ mdast-util-to-markdown ] (to support serializing
45
- expressions in syntax trees to markdown).
43
+ [ ` mdast-util-from-markdown ` ] [ github- mdast-util-from-markdown]
44
+ (to support parsing expressions in markdown into a syntax tree) and
45
+ [ ` mdast-util-to-markdown ` ] [ github- mdast-util-to-markdown]
46
+ (to support serializing expressions in syntax trees to markdown).
46
47
47
48
## When to use this
48
49
49
50
You can use these extensions when you are working with
50
51
` mdast-util-from-markdown ` and ` mdast-util-to-markdown ` already.
51
52
52
53
When working with ` mdast-util-from-markdown ` , you must combine this package
53
- with [ ` micromark-extension-mdx-expression ` ] [ extension ] .
54
+ with
55
+ [ ` micromark-extension-mdx-expression ` ] [ github-mm-extension-expression ] .
54
56
55
57
When you are working with syntax trees and want all of MDX, use
56
- [ ` mdast-util-mdx ` ] [ mdast-util-mdx ] instead.
58
+ [ ` mdast-util-mdx ` ] [ github- mdast-util-mdx] instead.
57
59
58
- All these packages are used in [ ` remark-mdx ` ] [ remark-mdx ] , which
59
- focusses on making it easier to transform content by abstracting these
60
- internals away.
60
+ All these packages are used in [ ` remark-mdx ` ] [ github- remark-mdx] ,
61
+ which focusses on making it easier to transform content by abstracting
62
+ these internals away.
61
63
62
64
## Install
63
65
@@ -189,26 +191,31 @@ There is no default export.
189
191
190
192
### ` mdxExpressionFromMarkdown() `
191
193
192
- Create an extension for [ ` mdast-util-from-markdown ` ] [ mdast-util-from-markdown ]
194
+ Create an extension for
195
+ [ ` mdast-util-from-markdown ` ] [ github-mdast-util-from-markdown ]
193
196
to enable MDX expressions in markdown.
194
197
195
- When using the [ micromark syntax extension] [ extension ] with ` addResult ` , nodes
196
- will have a ` data.estree ` field set to an ESTree [ ` Program ` ] [ program ] node.
198
+ When using the
199
+ [ micromark syntax extension] [ github-mm-extension-expression ]
200
+ with ` addResult ` ,
201
+ nodes will have a ` data.estree ` field set to an ESTree
202
+ [ ` Program ` ] [ github-estree-program ] node.
197
203
198
204
###### Returns
199
205
200
206
Extension for ` mdast-util-from-markdown ` to enable MDX expressions
201
- ([ ` FromMarkdownExtension ` ] [ from-markdown-extension ] ).
207
+ ([ ` FromMarkdownExtension ` ] [ github-mdast-util- from-markdown-extension] ).
202
208
203
209
### ` mdxExpressionToMarkdown() `
204
210
205
- Create an extension for [ ` mdast-util-to-markdown ` ] [ mdast-util-to-markdown ]
211
+ Create an extension for
212
+ [ ` mdast-util-to-markdown ` ] [ github-mdast-util-to-markdown ]
206
213
to enable MDX expressions in markdown.
207
214
208
215
###### Returns
209
216
210
217
Extension for ` mdast-util-to-markdown ` to enable MDX expressions
211
- ([ ` ToMarkdownExtension ` ] [ to-markdown-extension ] ).
218
+ ([ ` ToMarkdownExtension ` ] [ github-mdast-util- to-markdown-extension] ).
212
219
213
220
### ` MdxFlowExpression `
214
221
@@ -297,16 +304,18 @@ interface MdxTextExpressionData extends Data {
297
304
MDX expressions have no representation in HTML.
298
305
Though, when you are dealing with MDX, you will likely go * through* hast.
299
306
You can enable passing MDX expressions through to hast by configuring
300
- [ ` mdast-util-to-hast ` ] [ mdast-util-to-hast ] with
307
+ [ ` mdast-util-to-hast ` ] [ github- mdast-util-to-hast] with
301
308
` passThrough: ['mdxFlowExpression', 'mdxTextExpression'] ` .
302
309
303
310
## Syntax
304
311
305
- See [ Syntax in ` micromark-extension-mdx-expression ` ] [ syntax ] .
312
+ See [ Syntax in
313
+ ` micromark-extension-mdx-expression ` ] ( https://github.com/micromark/micromark-extension-mdx-expression#syntax ) .
306
314
307
315
## Syntax tree
308
316
309
- The following interfaces are added to ** [ mdast] [ ] ** by this utility.
317
+ The following interfaces are added to ** [ mdast] [ github-mdast ] **
318
+ by this utility.
310
319
311
320
### Nodes
312
321
@@ -318,9 +327,9 @@ interface MdxFlowExpression <: Literal {
318
327
}
319
328
```
320
329
321
- ** MdxFlowExpression** (** [ Literal] [ dfn- literal] ** ) represents a JavaScript
322
- expression embedded in flow (block).
323
- It can be used where ** [ flow] [ dfn -flow-content] ** content is expected.
330
+ ** MdxFlowExpression** (** [ Literal] [ github-mdast- literal] ** )
331
+ represents a JavaScript expression embedded in flow (block).
332
+ It can be used where ** [ flow] [ api -flow-content] ** content is expected.
324
333
Its content is represented by its ` value ` field.
325
334
326
335
For example, the following markdown:
@@ -345,9 +354,9 @@ interface MdxTextExpression <: Literal {
345
354
}
346
355
```
347
356
348
- ** MdxTextExpression** (** [ Literal] [ dfn- literal] ** ) represents a JavaScript
349
- expression embedded in text (span, inline).
350
- It can be used where ** [ phrasing] [ dfn -phrasing-content] ** content is expected.
357
+ ** MdxTextExpression** (** [ Literal] [ github-mdast- literal] ** )
358
+ represents a JavaScript expression embedded in text (span, inline).
359
+ It can be used where ** [ phrasing] [ api -phrasing-content] ** content is expected.
351
360
Its content is represented by its ` value ` field.
352
361
353
362
For example, the following markdown:
@@ -419,20 +428,20 @@ This utility works with `mdast-util-from-markdown` version 2+ and
419
428
420
429
## Related
421
430
422
- * [ ` remarkjs/ remark-mdx` ] [ remark-mdx ]
431
+ * [ ` remark-mdx ` ] [ github- remark-mdx]
423
432
— remark plugin to support MDX
424
- * [ ` syntax-tree/ mdast-util-mdx` ] [ mdast-util-mdx ]
433
+ * [ ` mdast-util-mdx ` ] [ github- mdast-util-mdx]
425
434
— mdast utility to support MDX
426
- * [ ` micromark/micromark -extension-mdx-expression ` ] [ extension ]
435
+ * [ ` micromark-extension-mdx-expression ` ] [ github-mm- extension-expression ]
427
436
— micromark extension to parse MDX expressions
428
437
429
438
## Contribute
430
439
431
- See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
432
- ways to get started.
433
- See [ ` support.md ` ] [ support ] for ways to get help.
440
+ See [ ` contributing.md ` ] [ health- contributing] in
441
+ [ ` syntax-tree/.github ` ] [ health ] for ways to get started.
442
+ See [ ` support.md ` ] [ health- support] for ways to get help.
434
443
435
- This project has a [ code of conduct] [ coc ] .
444
+ This project has a [ code of conduct] [ health- coc] .
436
445
By interacting with this repository, organization, or community you agree to
437
446
abide by its terms.
438
447
@@ -442,90 +451,88 @@ abide by its terms.
442
451
443
452
<!-- Definitions -->
444
453
445
- [ build-badge ] : https://github.com/syntax-tree/mdast-util- mdx-expression/workflows/main/badge.svg
454
+ [ api-flow-content ] : #flowcontent- mdx-expression
446
455
447
- [ build ] : https://github.com/syntax-tree/mdast-util- mdx-expression/actions
456
+ [ api- mdx-expression-from-markdown ] : #mdxexpressionfrommarkdown
448
457
449
- [ coverage-badge ] : https://img.shields.io/codecov/c/github/syntax-tree/mdast-util- mdx-expression.svg
458
+ [ api- mdx-expression-to-markdown ] : #mdxexpressiontomarkdown
450
459
451
- [ coverage ] : https://codecov.io/github/syntax-tree/mdast-util- mdx-expression
460
+ [ api- mdx-flow- expression] : #mdxflowexpression
452
461
453
- [ downloads-badge ] : https://img.shields.io/npm/dm/mdast-util- mdx-expression.svg
462
+ [ api- mdx-flow- expression-hast ] : #mdxflowexpressionhast
454
463
455
- [ downloads ] : https://www.npmjs.com/package/mdast-util- mdx-expression
464
+ [ api- mdx-text- expression] : #mdxtextexpression
456
465
457
- [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util- mdx-expression
466
+ [ api- mdx-text- expression-hast ] : #mdxtextexpressionhast
458
467
459
- [ size ] : https://bundlejs.com/?q=mdast-util -mdx-expression
468
+ [ api-phrasing-content ] : #phrasingcontent -mdx-expression
460
469
461
- [ sponsors-badge ] : https://opencollective .com/unified/sponsors/badge.svg
470
+ [ author ] : https://wooorm .com
462
471
463
472
[ backers-badge ] : https://opencollective.com/unified/backers/badge.svg
464
473
465
- [ collective ] : https://opencollective .com/unified
474
+ [ build ] : https://github .com/syntax-tree/mdast-util-mdx-expression/actions
466
475
467
- [ chat -badge] : https://img.shields.io/badge/chat-discussions-success .svg
476
+ [ build -badge] : https://github.com/syntax-tree/mdast-util-mdx-expression/workflows/main/badge .svg
468
477
469
478
[ chat ] : https://github.com/syntax-tree/unist/discussions
470
479
471
- [ npm ] : https://docs.npmjs.com/cli/install
472
-
473
- [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
480
+ [ chat-badge ] : https://img.shields.io/badge/chat-discussions-success.svg
474
481
475
- [ esmsh ] : https://esm.sh
482
+ [ collective ] : https://opencollective.com/unified
476
483
477
- [ typescript ] : https://www.typescriptlang.org
484
+ [ coverage ] : https://codecov.io/github/syntax-tree/mdast-util-mdx-expression
478
485
479
- [ license ] : license
486
+ [ coverage-badge ] : https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-mdx-expression.svg
480
487
481
- [ author ] : https://wooorm. com
488
+ [ downloads ] : https://www.npmjs. com/package/mdast-util-mdx-expression
482
489
483
- [ health ] : https://github.com/syntax-tree/.github
490
+ [ downloads-badge ] : https://img.shields.io/npm/dm/mdast-util-mdx-expression.svg
484
491
485
- [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
492
+ [ esm ] : https://gist. github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
486
493
487
- [ support ] : https://github.com/syntax-tree/.github/blob/main/support.md
494
+ [ esmsh ] : https://esm.sh
488
495
489
- [ coc ] : https://github.com/syntax-tree/.github /blob/main/code-of-conduct .md
496
+ [ github-estree-program ] : https://github.com/estree/estree /blob/master/es2015 .md#programs
490
497
491
- [ mdast ] : https://github.com/syntax-tree/mdast
498
+ [ github- mdast] : https://github.com/syntax-tree/mdast
492
499
493
- [ mdast-util-to-hast ] : https://github.com/syntax-tree/mdast-util-to-hast
500
+ [ github- mdast-literal ] : https://github.com/syntax-tree/mdast#literal
494
501
495
- [ mdast-util-from-markdown ] : https://github.com/syntax-tree/mdast-util-from-markdown
502
+ [ github- mdast-util-from-markdown] : https://github.com/syntax-tree/mdast-util-from-markdown
496
503
497
- [ mdast-util-to -markdown ] : https://github.com/syntax-tree/mdast-util-to -markdown
504
+ [ github- mdast-util-from -markdown-extension ] : https://github.com/syntax-tree/mdast-util-from -markdown#extension
498
505
499
- [ mdast-util-mdx ] : https://github.com/syntax-tree/mdast-util-mdx
506
+ [ github- mdast-util-mdx] : https://github.com/syntax-tree/mdast-util-mdx
500
507
501
- [ extension ] : https://github.com/micromark/micromark-extension-mdx-expression
508
+ [ github-mdast-util-to-hast ] : https://github.com/syntax-tree/mdast-util-to-hast
502
509
503
- [ syntax ] : https://github.com/micromark/micromark-extension-mdx-expression#syntax
510
+ [ github-mdast-util-to-markdown ] : https://github.com/syntax-tree/mdast-util-to-markdown
504
511
505
- [ program ] : https://github.com/estree/estree/blob/master/es2015.md#programs
512
+ [ github-mdast-util-to-markdown-extension ] : https://github.com/syntax-tree/mdast-util-to-markdown#options
506
513
507
- [ dfn-literal ] : https://github.com/syntax-tree/mdast#literal
514
+ [ github-mm-extension-expression ] : https://github.com/micromark/micromark-extension-mdx-expression
508
515
509
- [ remark-mdx ] : https://mdxjs.com/packages/remark-mdx/
516
+ [ github- remark-mdx] : https://mdxjs.com/packages/remark-mdx/
510
517
511
- [ mdx ] : https://mdxjs .com
518
+ [ health ] : https://github .com/syntax-tree/.github
512
519
513
- [ from-markdown-extension ] : https://github.com/syntax-tree/mdast-util-from-markdown#extension
520
+ [ health-coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
514
521
515
- [ to-markdown-extension ] : https://github.com/syntax-tree/mdast-util-to-markdown#options
522
+ [ health-contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
516
523
517
- [ api-mdx-expression-from-markdown ] : #mdxexpressionfrommarkdown
524
+ [ health-support ] : https://github.com/syntax-tree/.github/blob/main/support.md
518
525
519
- [ api-mdx-expression-to-markdown ] : #mdxexpressiontomarkdown
526
+ [ license ] : license
520
527
521
- [ api-mdx-flow-expression ] : #mdxflowexpression
528
+ [ mdxjs ] : https://mdxjs.com
522
529
523
- [ api-mdx-text-expression ] : #mdxtextexpression
530
+ [ npm ] : https://docs.npmjs.com/cli/install
524
531
525
- [ api- mdx-flow- expression-hast ] : #mdxflowexpressionhast
532
+ [ size ] : https://bundlejs.com/?q=mdast-util- mdx-expression
526
533
527
- [ api-mdx-text-expression-hast ] : #mdxtextexpressionhast
534
+ [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-mdx-expression
528
535
529
- [ dfn-flow-content ] : #flowcontent-mdx-expression
536
+ [ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
530
537
531
- [ dfn-phrasing-content ] : #phrasingcontent-mdx-expression
538
+ [ typescript ] : https://www.typescriptlang.org
0 commit comments