11# mdast-util-directive
22
3- [ ![ Build] [ build-badge ]] [ build ]
4- [ ![ Coverage] [ coverage-badge ]] [ coverage ]
5- [ ![ Downloads] [ downloads-badge ]] [ downloads ]
6- [ ![ Size] [ size-badge ]] [ size ]
7- [ ![ Sponsors] [ sponsors-badge ]] [ collective ]
8- [ ![ Backers] [ backers-badge ]] [ collective ]
9- [ ![ Chat] [ chat-badge ]] [ chat ]
10-
11- [ mdast] [ ] extensions to parse and serialize [ generic directives proposal] [ prop ]
3+ [ ![ Build] [ badge-build-image ]] [ badge-build-url ]
4+ [ ![ Coverage] [ badge-coverage-image ]] [ badge-coverage-url ]
5+ [ ![ Downloads] [ badge-downloads-image ]] [ badge-downloads-url ]
6+ [ ![ Size] [ badge-size-image ]] [ badge-size-url ]
7+
8+ [ mdast] [ github-mdast ] extensions to parse and serialize
9+ [ generic directives proposal] [ commonmark-directive-proposal ]
1210(` :cite[smith04] ` , ` ::youtube[Video of a cat in a box]{v=01ab2cd3efg} ` , and
1311such).
1412
@@ -40,18 +38,19 @@ such).
4038## What is this?
4139
4240This package contains two extensions that add support for directive syntax in
43- markdown to [ mdast] [ ] .
41+ markdown to [ mdast] [ github-mdast ] .
4442These extensions plug into
45- [ ` mdast-util-from-markdown ` ] [ mdast-util-from-markdown ] (to support parsing
46- directives in markdown into a syntax tree) and
47- [ ` mdast-util-to-markdown ` ] [ mdast-util-to-markdown ] (to support serializing
48- directives in syntax trees to markdown).
43+ [ ` mdast-util-from-markdown ` ] [ github-mdast-util-from-markdown ]
44+ (to support parsing directives in markdown into a syntax tree)
45+ and
46+ [ ` mdast-util-to-markdown ` ] [ github-mdast-util-to-markdown ]
47+ (to support serializing directives in syntax trees to markdown).
4948
5049## When to use this
5150
5251Directives are one of the four ways to extend markdown: an arbitrary extension
53- syntax (see [ Extending markdown] [ extending-markdown ] in micromark’s docs for
54- the alternatives and more info).
52+ syntax (see [ Extending markdown] [ github-micromark-extending ] in micromark’s
53+ docs for the alternatives and more info).
5554This mechanism works well when you control the content: who authors it, what
5655tools handle it, and where it’s displayed.
5756When authors can read a guide on how to embed a tweet but are not expected to
@@ -65,25 +64,27 @@ You can use these extensions when you are working with
6564` mdast-util-from-markdown ` and ` mdast-util-to-markdown ` already.
6665
6766When working with ` mdast-util-from-markdown ` , you must combine this package
68- with [ ` micromark-extension-directive ` ] [ extension ] .
67+ with
68+ [ ` micromark-extension-directive ` ] [ github-micromark-extension-directive ] .
6969
70- When you don’t need a syntax tree, you can use [ ` micromark ` ] [ micromark ]
70+ When you don’t need a syntax tree, you can use [ ` micromark ` ] [ github- micromark]
7171directly with ` micromark-extension-directive ` .
7272
73- All these packages are used [ ` remark-directive ` ] [ remark-directive ] , which
73+ All these packages are used [ ` remark-directive ` ] [ github- remark-directive] , which
7474focusses on making it easier to transform content by abstracting these
7575internals away.
7676
7777This package only handles the syntax tree.
7878For example, it does not handle how markdown is turned to HTML.
7979You can use this with some more code to match your specific needs, to allow for
8080anything from callouts, citations, styled blocks, forms, embeds, spoilers, etc.
81- [ Traverse the tree] [ traversal ] to change directives to whatever you please.
81+ [ Traverse the tree] [ unifiedjs-tree-traversal ] to change directives to whatever
82+ you please.
8283
8384## Install
8485
85- This package is [ ESM only] [ esm ] .
86- In Node.js (version 16+), install with [ npm] [ ] :
86+ This package is [ ESM only] [ github-gist- esm] .
87+ In Node.js (version 16+), install with [ npm] [ npmjs-install ] :
8788
8889``` sh
8990npm install mdast-util-directive
@@ -170,17 +171,19 @@ There is no default export.
170171
171172### ` directiveFromMarkdown() `
172173
173- Create an extension for [ ` mdast-util-from-markdown ` ] [ mdast-util-from-markdown ]
174+ Create an extension for
175+ [ ` mdast-util-from-markdown ` ] [ github-mdast-util-from-markdown ]
174176to enable directives in markdown.
175177
176178###### Returns
177179
178180Extension for ` mdast-util-from-markdown ` to enable directives
179- ([ ` FromMarkdownExtension ` ] [ from-markdown-extension ] ).
181+ ([ ` FromMarkdownExtension ` ] [ github-mdast- from-markdown-extension] ).
180182
181183### ` directiveToMarkdown(options?) `
182184
183- Create an extension for [ ` mdast-util-to-markdown ` ] [ mdast-util-to-markdown ]
185+ Create an extension for
186+ [ ` mdast-util-to-markdown ` ] [ github-mdast-util-to-markdown ]
184187to enable directives in markdown.
185188
186189###### Parameters
@@ -192,7 +195,7 @@ to enable directives in markdown.
192195###### Returns
193196
194197Extension for ` mdast-util-to-markdown ` to enable directives
195- ([ ` ToMarkdownExtension ` ] [ to-markdown-extension ] ).
198+ ([ ` ToMarkdownExtension ` ] [ github-mdast- to-markdown-extension] ).
196199
197200### ` ContainerDirective `
198201
@@ -278,23 +281,26 @@ Configuration.
278281 — use the other quote if that results in less bytes
279282* ` quote `
280283 (` '"' ` or ` "'" ` ,
281- default: the [ ` quote ` ] [ quote ] used by ` mdast-util-to-markdown ` for titles)
284+ default: the [ ` quote ` ] [ github-mdast-util-to-markdown-quote ]
285+ used by ` mdast-util-to-markdown ` for titles)
282286 — preferred quote to use around attribute values
283287
284288## HTML
285289
286290This utility does not handle how markdown is turned to HTML.
287291You can use this with some more code to match your specific needs, to allow for
288292anything from callouts, citations, styled blocks, forms, embeds, spoilers, etc.
289- [ Traverse the tree] [ traversal ] to change directives to whatever you please.
293+ [ Traverse the tree] [ unifiedjs-tree-traversal ] to change directives to whatever
294+ you please.
290295
291296## Syntax
292297
293- See [ Syntax in ` micromark-extension-directive ` ] [ syntax ] .
298+ See [ Syntax in
299+ ` micromark-extension-directive ` ] [ github-micromark-extension-directive-syntax ] .
294300
295301## Syntax tree
296302
297- The following interfaces are added to ** [ mdast] [ ] ** by this utility.
303+ The following interfaces are added to ** [ mdast] [ github-mdast ] ** by this utility.
298304
299305### Nodes
300306
@@ -309,10 +315,12 @@ interface TextDirective <: Parent {
309315TextDirective includes Directive
310316```
311317
312- ** TextDirective** (** [ Parent] [ dfn-parent ] ** ) is a directive.
313- It can be used where ** [ phrasing] [ dfn-phrasing-content ] ** content is expected.
314- Its content model is also ** [ phrasing] [ dfn-phrasing-content ] ** content.
315- It includes the mixin ** [ Directive] [ dfn-mxn-directive ] ** .
318+ ** TextDirective** (** [ Parent] [ github-mdast-parent ] ** ) is a directive.
319+ It can be used where ** [ phrasing] [ github-mdast-phrasing-content ] ** content is
320+ expected.
321+ Its content model is also ** [ phrasing] [ github-mdast-phrasing-content ] **
322+ content.
323+ It includes the mixin ** [ Directive] [ syntax-tree-mixin-directive ] ** .
316324
317325For example, the following Markdown:
318326
@@ -342,10 +350,10 @@ interface LeafDirective <: Parent {
342350LeafDirective includes Directive
343351```
344352
345- ** LeafDirective** (** [ Parent] [ dfn -parent] ** ) is a directive.
346- It can be used where ** [ flow] [ dfn -flow-content] ** content is expected.
347- Its content model is ** [ phrasing] [ dfn -phrasing-content] ** content.
348- It includes the mixin ** [ Directive] [ dfn-mxn -directive] ** .
353+ ** LeafDirective** (** [ Parent] [ github-mdast -parent] ** ) is a directive.
354+ It can be used where ** [ flow] [ github-mdast -flow-content] ** content is expected.
355+ Its content model is ** [ phrasing] [ github-mdast -phrasing-content] ** content.
356+ It includes the mixin ** [ Directive] [ syntax-tree-mixin -directive] ** .
349357
350358For example, the following Markdown:
351359
@@ -375,10 +383,10 @@ interface ContainerDirective <: Parent {
375383ContainerDirective includes Directive
376384```
377385
378- ** ContainerDirective** (** [ Parent] [ dfn -parent] ** ) is a directive.
379- It can be used where ** [ flow] [ dfn -flow-content] ** content is expected.
380- Its content model is also ** [ flow] [ dfn -flow-content] ** content.
381- It includes the mixin ** [ Directive] [ dfn-mxn -directive] ** .
386+ ** ContainerDirective** (** [ Parent] [ github-mdast -parent] ** ) is a directive.
387+ It can be used where ** [ flow] [ github-mdast -flow-content] ** content is expected.
388+ Its content model is also ** [ flow] [ github-mdast -flow-content] ** content.
389+ It includes the mixin ** [ Directive] [ syntax-tree-mixin -directive] ** .
382390
383391The phrasing in the label is, when available, added as a paragraph with a
384392` directiveLabel: true ` field, as the head of its content.
@@ -485,117 +493,109 @@ This utility works with `mdast-util-from-markdown` version 2+ and
485493
486494## Related
487495
488- * [ ` remarkjs/ remark-directive` ] [ remark-directive ]
496+ * [ ` remark-directive ` ] [ github- remark-directive]
489497 — remark plugin to support generic directives
490- * [ ` micromark/micromark -extension-directive ` ] [ extension ]
498+ * [ ` micromark-extension-directive ` ] [ github-micromark- extension-directive ]
491499 — micromark extension to parse directives
492500
493501## Contribute
494502
495- See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
496- ways to get started.
497- See [ ` support.md ` ] [ support ] for ways to get help.
503+ See [ ` contributing.md ` ] [ health-contributing ]
504+ in
505+ [ ` syntax-tree/.github ` ] [ health ]
506+ for ways to get started.
507+ See [ ` support.md ` ] [ health-support ] for ways to get help.
498508
499- This project has a [ code of conduct] [ coc ] .
509+ This project has a [ code of conduct] [ health- coc] .
500510By interacting with this repository, organization, or community you agree to
501511abide by its terms.
502512
503513## License
504514
505- [ MIT] [ license ] © [ Titus Wormer] [ author ]
515+ [ MIT] [ file- license] © [ Titus Wormer] [ wooorm ]
506516
507517<!-- Definitions -->
508518
509- [ build-badge ] : https://github.com/syntax-tree/mdast-util-directive/workflows/main/badge.svg
510-
511- [ build ] : https://github.com/syntax-tree/mdast-util-directive/actions
512-
513- [ coverage-badge ] : https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-directive.svg
514-
515- [ coverage ] : https://codecov.io/github/syntax-tree/mdast-util-directive
516-
517- [ downloads-badge ] : https://img.shields.io/npm/dm/mdast-util-directive.svg
518-
519- [ downloads ] : https://www.npmjs.com/package/mdast-util-directive
519+ [ api-container-directive ] : #containerdirective
520520
521- [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-directive
521+ [ api-directive-from-markdown ] : #directivefrommarkdown
522522
523- [ size ] : https://bundlejs.com/?q=mdast-util-directive
523+ [ api-directive-to-markdown ] : #directivetomarkdownoptions
524524
525- [ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
525+ [ api-directives ] : #directives
526526
527- [ backers-badge ] : https://opencollective.com/unified/backers/badge.svg
527+ [ api-leaf-directive ] : #leafdirective
528528
529- [ collective ] : https://opencollective.com/unified
529+ [ api-text-directive ] : #textdirective
530530
531- [ chat-badge ] : https://img.shields.io/badge/chat-discussions-success.svg
531+ [ api-to-markdown-options ] : #tomarkdownoptions
532532
533- [ chat ] : https://github.com/syntax-tree/unist/discussions
533+ [ badge-build-image ] : https://github.com/syntax-tree/mdast-util-directive/workflows/main/badge.svg
534534
535- [ npm ] : https://docs.npmjs. com/cli/install
535+ [ badge-build-url ] : https://github. com/syntax-tree/mdast-util-directive/actions
536536
537- [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
537+ [ badge-coverage-image ] : https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-directive.svg
538538
539- [ esmsh ] : https://esm.sh
539+ [ badge-coverage-url ] : https://codecov.io/github/syntax-tree/mdast-util-directive
540540
541- [ typescript ] : https://www.typescriptlang.org
541+ [ badge-downloads-image ] : https://img.shields.io/npm/dm/mdast-util-directive.svg
542542
543- [ license ] : license
543+ [ badge-downloads-url ] : https://www.npmjs.com/package/mdast-util-directive
544544
545- [ author ] : https://wooorm.com
545+ [ badge-size-image ] : https://img.shields.io/bundlejs/size/mdast-util-directive
546546
547- [ health ] : https://github .com/syntax-tree/.github
547+ [ badge-size-url ] : https://bundlejs .com/?q=mdast-util-directive
548548
549- [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
549+ [ commonmark-directive-proposal ] : https://talk.commonmark.org/t/generic-directives-plugins-syntax/444
550550
551- [ support ] : https://github.com/syntax-tree/.github/blob/main/support.md
551+ [ esmsh ] : https://esm.sh
552552
553- [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
553+ [ file-license ] : license
554554
555- [ mdast ] : https://github.com/syntax-tree/mdast
555+ [ github-gist-esm ] : https://gist. github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
556556
557- [ mdast-util-from-markdown ] : https://github.com/syntax-tree/mdast-util-from-markdown
557+ [ github-mdast ] : https://github.com/syntax-tree/mdast
558558
559- [ mdast-util-to-markdown ] : https://github.com/syntax-tree/mdast-util-to-markdown
559+ [ github- mdast-flow-content ] : https://github.com/syntax-tree/mdast#flowcontent
560560
561- [ quote ] : https://github.com/syntax-tree/mdast-util-to -markdown#optionsquote
561+ [ github-mdast-from-markdown-extension ] : https://github.com/syntax-tree/mdast-util-from -markdown#extension
562562
563- [ micromark ] : https://github.com/micromark/micromark
563+ [ github-mdast-parent ] : https://github.com/syntax-tree/mdast#parent
564564
565- [ extension ] : https://github.com/micromark/micromark-extension-directive
565+ [ github-mdast-phrasing-content ] : https://github.com/syntax-tree/mdast#phrasingcontent
566566
567- [ syntax ] : https://github.com/micromark/micromark-extension-directive#syntax
567+ [ github-mdast-to-markdown-extension ] : https://github.com/syntax-tree/mdast-util-to-markdown#options
568568
569- [ remark-directive ] : https://github.com/remarkjs/remark-directive
569+ [ github-mdast-util-from-markdown ] : https://github.com/syntax-tree/mdast-util-from-markdown
570570
571- [ extending- markdown] : https://github.com/micromark/micromark#extending -markdown
571+ [ github-mdast-util-to- markdown] : https://github.com/syntax-tree/mdast-util-to -markdown
572572
573- [ prop ] : https://talk.commonmark.org/t/generic-directives-plugins-syntax/444
573+ [ github-mdast-util-to-markdown-quote ] : https://github.com/syntax-tree/mdast-util-to-markdown#optionsquote
574574
575- [ traversal ] : https://unifiedjs .com/learn/recipe/tree-traversal/
575+ [ github-micromark ] : https://github .com/micromark/micromark
576576
577- [ dfn-parent ] : https://github.com/syntax-tree/mdast#parent
577+ [ github-micromark-extending ] : https://github.com/micromark/micromark#extending-markdown
578578
579- [ dfn-flow-content ] : https://github.com/syntax-tree/mdast#flowcontent
579+ [ github-micromark-extension-directive ] : https://github.com/micromark/micromark-extension-directive
580580
581- [ dfn-phrasing-content ] : https://github.com/syntax-tree/mdast#phrasingcontent
581+ [ github-micromark-extension-directive-syntax ] : https://github.com/micromark/micromark-extension-directive#syntax
582582
583- [ from-markdown-extension ] : https://github.com/syntax-tree/mdast-util-from-markdown#extension
583+ [ github-remark-directive ] : https://github.com/remarkjs/remark-directive
584584
585- [ to-markdown-extension ] : https://github.com/syntax-tree/mdast-util-to-markdown#options
585+ [ health ] : https://github.com/syntax-tree/.github
586586
587- [ api-directive-from-markdown ] : #directivefrommarkdown
587+ [ health-coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
588588
589- [ api-directive-to-markdown ] : #directivetomarkdownoptions
589+ [ health-contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
590590
591- [ api-to-markdown-options ] : #tomarkdownoptions
591+ [ health-support ] : https://github.com/syntax-tree/.github/blob/main/support.md
592592
593- [ api-container-directive ] : #containerdirective
593+ [ npmjs-install ] : https://docs.npmjs.com/cli/install
594594
595- [ api-directives ] : #directives
595+ [ syntax-tree-mixin-directive ] : #directive
596596
597- [ api-leaf-directive ] : #leafdirective
597+ [ typescript ] : https://www.typescriptlang.org
598598
599- [ api-text-directive ] : #textdirective
599+ [ unifiedjs-tree-traversal ] : https://unifiedjs.com/learn/recipe/tree-traversal/
600600
601- [ dfn-mxn-directive ] : #directive
601+ [ wooorm ] : https://wooorm.com
0 commit comments