8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- ** [ mdast] [ ] ** utility that turns a syntax tree into markdown.
11
+ ** [ mdast] [ github-mdast ] ** utility that turns a syntax tree into markdown.
12
12
13
13
## Contents
14
14
43
43
44
44
## What is this?
45
45
46
- This package is a utility that takes an [ mdast] [ ] syntax tree as input and turns
47
- it into serialized markdown.
46
+ This package is a utility that takes an [ mdast] [ github-mdast ]
47
+ syntax tree as input and turns it into serialized markdown.
48
48
49
49
This utility is a low level project.
50
- It’s used in [ ` remark-stringify ` ] [ remark-stringify ] , which focusses on making it
51
- easier to transform content by abstracting these internals away.
50
+ It’s used in [ ` remark-stringify ` ] [ github-remark-stringify ] ,
51
+ which focusses on making it easier to transform content by abstracting
52
+ these internals away.
52
53
53
54
## When should I use this?
54
55
55
56
If you want to handle syntax trees manually, use this.
56
- For an easier time processing content, use the ** [ remark] [ ] ** ecosystem instead.
57
+ For an easier time processing content, use the ** [ remark] [ github-remark ] **
58
+ ecosystem instead.
57
59
58
60
You can combine this utility with other utilities to add syntax extensions.
59
61
Notable examples that deeply integrate with it are
60
- [ ` mdast-util-gfm ` ] [ mdast-util-gfm ] ,
61
- [ ` mdast-util-mdx ` ] [ mdast-util-mdx ] ,
62
- [ ` mdast-util-frontmatter ` ] [ mdast-util-frontmatter ] ,
63
- [ ` mdast-util-math ` ] [ mdast-util-math ] , and
64
- [ ` mdast-util-directive ` ] [ mdast-util-directive ] .
62
+ [ ` mdast-util-gfm ` ] [ github- mdast-util-gfm] ,
63
+ [ ` mdast-util-mdx ` ] [ github- mdast-util-mdx] ,
64
+ [ ` mdast-util-frontmatter ` ] [ github- mdast-util-frontmatter] ,
65
+ [ ` mdast-util-math ` ] [ github- mdast-util-math] , and
66
+ [ ` mdast-util-directive ` ] [ github- mdast-util-directive] .
65
67
66
68
## Install
67
69
@@ -144,11 +146,11 @@ There is no default export.
144
146
145
147
### ` toMarkdown(tree[, options]) `
146
148
147
- Turn an ** [ mdast] [ ] ** syntax tree into markdown.
149
+ Turn an ** [ mdast] [ github-mdast ] ** syntax tree into markdown.
148
150
149
151
###### Parameters
150
152
151
- * ` tree ` ([ ` Node ` ] [ node ] )
153
+ * ` tree ` ([ ` Node ` ] [ github-mdast-nodes ] )
152
154
— tree to serialize
153
155
* ` options ` ([ ` Options ` ] [ api-options ] , optional)
154
156
— configuration
@@ -206,7 +208,7 @@ Handle a particular node (TypeScript type).
206
208
207
209
* ` node ` (` any ` )
208
210
— expected mdast node
209
- * ` parent ` ([ ` Node ` ] [ node ] , optional)
211
+ * ` parent ` ([ ` Node ` ] [ github-mdast-nodes ] , optional)
210
212
— parent of ` node `
211
213
* ` state ` ([ ` State ` ] [ api-state ] )
212
214
— info passed around about the current state
@@ -236,7 +238,7 @@ Info on the surrounding of the node that is serialized (TypeScript type).
236
238
237
239
###### Fields
238
240
239
- * ` now ` ([ ` Point ` ][point])
241
+ * ` now ` ([ ` Point ` ][github-unist- point])
240
242
— current point
241
243
* ` lineShift ` ( ` number ` )
242
244
— number of columns each line will be shifted by wrapping nodes
@@ -258,11 +260,11 @@ return defines how many blank lines to use between them.
258
260
259
261
###### Parameters
260
262
261
- * ` left ` ([ ` Node ` ][node ])
263
+ * ` left ` ([ ` Node ` ][github-mdast-nodes ])
262
264
— first of two adjacent siblings
263
- * ` right ` ([ ` Node ` ][node ])
265
+ * ` right ` ([ ` Node ` ][github-mdast-nodes ])
264
266
— second of two adjacent siblings
265
- * ` parent ` ([ ` Node ` ][node ])
267
+ * ` parent ` ([ ` Node ` ][github-mdast-nodes ])
266
268
— parent of the two siblings
267
269
* ` state ` ([ ` State ` ][api-state])
268
270
— info passed around about the current state
@@ -476,7 +478,7 @@ Info passed around about the current state (TypeScript type).
476
478
— positions of child nodes in their parents
477
479
* ` associationId ` (` (node: Association) => string ` )
478
480
— get an identifier from an association to match it to others (see
479
- [ ` Association ` ] [ association ] )
481
+ [ ` Association ` ] [ github-mdast- association] )
480
482
* ` enter ` (` (construct: ConstructName) => () => undefined ` )
481
483
— enter a construct (returns a corresponding exit function)
482
484
(see [ ` ConstructName ` ] [ api-construct-name ] )
@@ -548,11 +550,11 @@ Schema that defines when a character cannot occur (TypeScript type).
548
550
549
551
## List of extensions
550
552
551
- * [ ` syntax-tree/mdast-util-directive ` ] ( https:// github.com/syntax-tree/ mdast-util-directive)
553
+ * [ ` syntax-tree/mdast-util-directive ` ] [ github- mdast-util-directive ]
552
554
— directives
553
- * [ ` syntax-tree/mdast-util-frontmatter ` ] ( https:// github.com/syntax-tree/ mdast-util-frontmatter)
555
+ * [ ` syntax-tree/mdast-util-frontmatter ` ] [ github- mdast-util-frontmatter ]
554
556
— frontmatter (YAML, TOML, more)
555
- * [ ` syntax-tree/mdast-util-gfm ` ] ( https:// github.com/syntax-tree/ mdast-util-gfm)
557
+ * [ ` syntax-tree/mdast-util-gfm ` ] [ github- mdast-util-gfm ]
556
558
— GFM
557
559
* [ ` syntax-tree/mdast-util-gfm-autolink-literal ` ] ( https://github.com/syntax-tree/mdast-util-gfm-autolink-literal )
558
560
— GFM autolink literals
@@ -564,9 +566,9 @@ Schema that defines when a character cannot occur (TypeScript type).
564
566
— GFM tables
565
567
* [ ` syntax-tree/mdast-util-gfm-task-list-item ` ] ( https://github.com/syntax-tree/mdast-util-gfm-task-list-item )
566
568
— GFM task list items
567
- * [ ` syntax-tree/mdast-util-math ` ] ( https:// github.com/syntax-tree/ mdast-util-math)
569
+ * [ ` syntax-tree/mdast-util-math ` ] [ github- mdast-util-math ]
568
570
— math
569
- * [ ` syntax-tree/mdast-util-mdx ` ] ( https:// github.com/syntax-tree/ mdast-util-mdx)
571
+ * [ ` syntax-tree/mdast-util-mdx ` ] [ github- mdast-util-mdx ]
570
572
— MDX
571
573
* [ ` syntax-tree/mdast-util-mdx-expression ` ] ( https://github.com/syntax-tree/mdast-util-mdx-expression )
572
574
— MDX expressions
@@ -583,7 +585,7 @@ Extensions can add support for custom syntax.
583
585
584
586
## Syntax tree
585
587
586
- The syntax tree is [ mdast] [ ] .
588
+ The syntax tree is [ mdast] [ github-mdast ] .
587
589
588
590
## Types
589
591
@@ -619,132 +621,134 @@ It’ll do its best, but complete roundtripping is impossible given that any val
619
621
could be injected into the tree.
620
622
621
623
As markdown is sometimes used for HTML, and improper use of HTML can open you up
622
- to a [ cross-site scripting (XSS)] [ xss ] attack, use of ` mdast-util-to-markdown `
624
+ to a [ cross-site scripting (XSS)] [ wikipedia-xss ] attack,
625
+ use of ` mdast-util-to-markdown `
623
626
and parsing it again later could potentially be unsafe.
624
627
When parsing markdown afterwards and then going to HTML, use something like
625
- [ ` hast-util-sanitize ` ] [ hast-util-sanitize ] to make the tree safe.
628
+ [ ` hast-util-sanitize ` ] [ github- hast-util-sanitize] to make the tree safe.
626
629
627
630
## Related
628
631
629
632
* [ ` syntax-tree/mdast-util-from-markdown ` ] ( https://github.com/syntax-tree/mdast-util-from-markdown )
630
633
— parse markdown to mdast
631
634
* [ ` micromark/micromark ` ] ( https://github.com/micromark/micromark )
632
635
— parse markdown
633
- * [ ` remarkjs/remark ` ] ( https:// github.com/remarkjs/ remark)
636
+ * [ ` remarkjs/remark ` ] [ github- remark ]
634
637
— process markdown
635
638
636
639
## Contribute
637
640
638
- See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
641
+ See [ ` contributing.md ` ] [ health-contributing ] in
642
+ [ ` syntax-tree/.github ` ] [ health ] for
639
643
ways to get started.
640
- See [ ` support.md ` ] [ support ] for ways to get help.
644
+ See [ ` support.md ` ] [ health- support] for ways to get help.
641
645
642
- This project has a [ code of conduct] [ coc ] .
646
+ This project has a [ code of conduct] [ health- coc] .
643
647
By interacting with this repository, organization, or community you agree to
644
648
abide by its terms.
645
649
646
650
## License
647
651
648
- [ MIT] [ license ] © [ Titus Wormer] [ author ]
652
+ [ MIT] [ license ] © [ Titus Wormer] [ wooorm ]
649
653
650
654
<!-- Definitions -->
651
655
652
- [ build-badge ] : https://github.com/syntax-tree/mdast-util-to-markdown/workflows/main/badge.svg
656
+ [ api-construct-name ] : #constructname
653
657
654
- [ build ] : https://github.com/syntax-tree/mdast-util-to-markdown/actions
658
+ [ api-construct-name-map ] : #constructnamemap
655
659
656
- [ coverage-badge ] : https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-to-markdown.svg
660
+ [ api-default-handlers ] : #defaulthandlers
657
661
658
- [ coverage ] : https://codecov.io/github/syntax-tree/mdast-util-to-markdown
662
+ [ api-handle ] : #handle
659
663
660
- [ downloads-badge ] : https://img.shields.io/npm/dm/mdast-util-to-markdown.svg
664
+ [ api-handlers ] : #handlers
661
665
662
- [ downloads ] : https://www.npmjs.com/package/mdast-util-to-markdown
666
+ [ api-info ] : #info
663
667
664
- [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-to-markdown
668
+ [ api-join ] : #join
665
669
666
- [ size ] : https://bundlejs.com/?q=mdast-util-to-markdown
670
+ [ api-map ] : #map
667
671
668
- [ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
672
+ [ api-options ] : #options
669
673
670
- [ backers-badge ] : https://opencollective.com/unified/backers/badge.svg
674
+ [ api-safe-config ] : #safeconfig
671
675
672
- [ collective ] : https://opencollective.com/unified
676
+ [ api-state ] : #state
673
677
674
- [ chat-badge ] : https://img.shields.io/badge/chat-discussions-success.svg
678
+ [ api-to-markdown ] : #tomarkdowntree-options
675
679
676
- [ chat ] : https://github.com/syntax-tree/unist/discussions
680
+ [ api-tracker ] : #tracker
677
681
678
- [ npm ] : https://docs.npmjs.com/cli/install
682
+ [ api-unsafe ] : #unsafe
679
683
680
- [ esmsh ] : https://esm.sh
684
+ [ backers-badge ] : https://opencollective.com/unified/backers/badge.svg
681
685
682
- [ license ] : license
686
+ [ build ] : https://github.com/syntax-tree/mdast-util-to-markdown/actions
683
687
684
- [ author ] : https://wooorm .com
688
+ [ build-badge ] : https://github .com/syntax-tree/mdast-util-to-markdown/workflows/main/badge.svg
685
689
686
- [ health ] : https://github.com/syntax-tree/.github
690
+ [ chat ] : https://github.com/syntax-tree/unist/discussions
687
691
688
- [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
692
+ [ chat-badge ] : https://img.shields.io/badge/chat-discussions-success.svg
689
693
690
- [ support ] : https://github .com/syntax-tree/.github/blob/main/support.md
694
+ [ collective ] : https://opencollective .com/unified
691
695
692
- [ coc ] : https://github.com/ syntax-tree/.github/blob/main/code-of-conduct.md
696
+ [ coverage ] : https://codecov.io/github/ syntax-tree/mdast-util-to-markdown
693
697
694
- [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
698
+ [ coverage-badge ] : https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-to-markdown.svg
695
699
696
- [ typescript ] : https://www.typescriptlang.org
700
+ [ downloads ] : https://www.npmjs.com/package/mdast-util-to-markdown
697
701
698
- [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
702
+ [ downloads-badge ] : https://img.shields.io/npm/dm/mdast-util-to-markdown.svg
699
703
700
- [ hast-util-sanitize ] : https://github.com/syntax-tree/hast-util-sanitize
704
+ [ esm ] : https://gist. github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
701
705
702
- [ point ] : https://github.com/syntax-tree/unist#point
706
+ [ esmsh ] : https://esm.sh
703
707
704
- [ mdast ] : https://github.com/syntax-tree/mdast
708
+ [ github-hast-util-sanitize ] : https://github.com/syntax-tree/hast-util-sanitize
705
709
706
- [ node ] : https://github.com/syntax-tree/mdast#nodes
710
+ [ github-mdast ] : https://github.com/syntax-tree/mdast
707
711
708
- [ association ] : https://github.com/syntax-tree/mdast#association
712
+ [ github-mdast- association] : https://github.com/syntax-tree/mdast#association
709
713
710
- [ mdast-util-gfm ] : https://github.com/syntax-tree/mdast-util-gfm
714
+ [ github- mdast-nodes ] : https://github.com/syntax-tree/mdast#nodes
711
715
712
- [ mdast-util-mdx ] : https://github.com/syntax-tree/mdast-util-mdx
716
+ [ github- mdast-util-directive ] : https://github.com/syntax-tree/mdast-util-directive
713
717
714
- [ mdast-util-frontmatter ] : https://github.com/syntax-tree/mdast-util-frontmatter
718
+ [ github- mdast-util-frontmatter] : https://github.com/syntax-tree/mdast-util-frontmatter
715
719
716
- [ mdast-util-math ] : https://github.com/syntax-tree/mdast-util-math
720
+ [ github- mdast-util-gfm ] : https://github.com/syntax-tree/mdast-util-gfm
717
721
718
- [ mdast-util-directive ] : https://github.com/syntax-tree/mdast-util-directive
722
+ [ github- mdast-util-math ] : https://github.com/syntax-tree/mdast-util-math
719
723
720
- [ remark ] : https://github.com/remarkjs/remark
724
+ [ github-mdast-util-mdx ] : https://github.com/syntax-tree/mdast-util-mdx
721
725
722
- [ remark-stringify ] : https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
726
+ [ github-remark ] : https://github.com/remarkjs/remark
723
727
724
- [ api-construct-name ] : #constructname
728
+ [ github-remark-stringify ] : https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
725
729
726
- [ api-construct-name-map ] : #constructnamemap
730
+ [ github-unist-point ] : https://github.com/syntax-tree/unist#point
727
731
728
- [ api-default-handlers ] : #defaulthandlers
732
+ [ health ] : https://github.com/syntax-tree/.github
729
733
730
- [ api-handle ] : #handle
734
+ [ health-coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
731
735
732
- [ api-handlers ] : #handlers
736
+ [ health-contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
733
737
734
- [ api-info ] : #info
738
+ [ health-support ] : https://github.com/syntax-tree/.github/blob/main/support.md
735
739
736
- [ api-join ] : #join
740
+ [ license ] : license
737
741
738
- [ api-map ] : #map
742
+ [ npm ] : https://docs.npmjs.com/cli/install
739
743
740
- [ api-options ] : #options
744
+ [ size ] : https://bundlejs.com/?q=mdast-util-to-markdown
741
745
742
- [ api-safe-config ] : #safeconfig
746
+ [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-to-markdown
743
747
744
- [ api-state ] : #state
748
+ [ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
745
749
746
- [ api-to-markdown ] : #tomarkdowntree-options
750
+ [ typescript ] : https://www.typescriptlang.org
747
751
748
- [ api-tracker ] : #tracker
752
+ [ wikipedia-xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
749
753
750
- [ api-unsafe ] : #unsafe
754
+ [ wooorm ] : https://wooorm.com
0 commit comments