Skip to content

Commit 68f9e17

Browse files
committed
Refactor docs
1 parent 0672409 commit 68f9e17

File tree

1 file changed

+87
-50
lines changed

1 file changed

+87
-50
lines changed

readme.md

+87-50
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
[mdast][github-mdast] extensions to parse and serialize
99
[generic directives proposal][commonmark-directive-proposal]
10-
(`:cite[smith04]`, `::youtube[Video of a cat in a box]{v=01ab2cd3efg}`, and
11-
such).
10+
(`:cite[smith04]`,
11+
`::youtube[Video of a cat in a box]{v=01ab2cd3efg}`,
12+
and such).
1213

1314
## Contents
1415

@@ -48,43 +49,56 @@ and
4849

4950
## When to use this
5051

51-
Directives are one of the four ways to extend markdown: an arbitrary extension
52-
syntax (see [Extending markdown][github-micromark-extending] in micromark’s
53-
docs for the alternatives and more info).
54-
This mechanism works well when you control the content: who authors it, what
55-
tools handle it, and where it’s displayed.
52+
Directives are one of the four ways to extend markdown:
53+
an arbitrary extension syntax
54+
(see [Extending markdown][github-micromark-extending] in micromark’s docs for
55+
the alternatives and more info).
56+
This mechanism works well when you control the content:
57+
who authors it,
58+
what tools handle it,
59+
and where it’s displayed.
5660
When authors can read a guide on how to embed a tweet but are not expected to
5761
know the ins and outs of HTML or JavaScript.
58-
Directives don’t work well if you don’t know who authors content, what tools
59-
handle it, and where it ends up.
60-
Example use cases are a docs website for a project or product, or blogging tools
61-
and static site generators.
62+
Directives don’t work well if you don’t know who authors content,
63+
what tools handle it,
64+
and where it ends up.
65+
Example use cases are a docs website for a project or product,
66+
or blogging tools and static site generators.
6267

6368
You can use these extensions when you are working with
6469
`mdast-util-from-markdown` and `mdast-util-to-markdown` already.
6570

66-
When working with `mdast-util-from-markdown`, you must combine this package
67-
with
71+
When working with `mdast-util-from-markdown`,
72+
you must combine this package with
6873
[`micromark-extension-directive`][github-micromark-extension-directive].
6974

70-
When you don’t need a syntax tree, you can use [`micromark`][github-micromark]
71-
directly with `micromark-extension-directive`.
75+
When you don’t need a syntax tree,
76+
you can use [`micromark`][github-micromark] directly with
77+
`micromark-extension-directive`.
7278

73-
All these packages are used [`remark-directive`][github-remark-directive], which
74-
focusses on making it easier to transform content by abstracting these
79+
All these packages are used [`remark-directive`][github-remark-directive],
80+
which focusses on making it easier to transform content by abstracting these
7581
internals away.
7682

7783
This package only handles the syntax tree.
78-
For example, it does not handle how markdown is turned to HTML.
79-
You can use this with some more code to match your specific needs, to allow for
80-
anything from callouts, citations, styled blocks, forms, embeds, spoilers, etc.
84+
For example,
85+
it does not handle how markdown is turned to HTML.
86+
You can use this with some more code to match your specific needs,
87+
to allow for anything from callouts,
88+
citations,
89+
styled blocks,
90+
forms,
91+
embeds,
92+
spoilers,
93+
etc.
8194
[Traverse the tree][unifiedjs-tree-traversal] to change directives to whatever
8295
you please.
8396

8497
## Install
8598

8699
This package is [ESM only][github-gist-esm].
87-
In Node.js (version 16+), install with [npm][npmjs-install]:
100+
In Node.js (version 16+),
101+
install with [npm][npmjs-install]:
88102

89103
```sh
90104
npm install mdast-util-directive
@@ -199,8 +213,10 @@ Extension for `mdast-util-to-markdown` to enable directives
199213

200214
### `ContainerDirective`
201215

202-
Directive in flow content (such as in the root document, or block quotes),
203-
which contains further flow content (TypeScript type).
216+
Directive in flow content
217+
(such as in the root document or block quotes),
218+
which contains further flow content
219+
(TypeScript type).
204220

205221
###### Type
206222

@@ -217,7 +233,8 @@ interface ContainerDirective extends Parent {
217233

218234
### `Directives`
219235

220-
The different directive nodes (TypeScript type).
236+
The different directive nodes
237+
(TypeScript type).
221238

222239
###### Type
223240

@@ -227,8 +244,10 @@ type Directives = ContainerDirective | LeafDirective | TextDirective
227244
228245
### `LeafDirective`
229246
230-
Directive in flow content (such as in the root document, or block quotes),
231-
which contains nothing (TypeScript type).
247+
Directive in flow content
248+
(such as in the root document or block quotes),
249+
which contains nothing
250+
(TypeScript type).
232251
233252
###### Type
234253
@@ -245,8 +264,9 @@ interface LeafDirective extends Parent {
245264

246265
### `TextDirective`
247266

248-
Directive in phrasing content (such as in paragraphs, headings) (TypeScript
249-
type).
267+
Directive in phrasing content
268+
(such as in paragraphs and headings)
269+
(TypeScript type).
250270

251271
###### Type
252272

@@ -288,8 +308,14 @@ Configuration.
288308
## HTML
289309

290310
This utility does not handle how markdown is turned to HTML.
291-
You can use this with some more code to match your specific needs, to allow for
292-
anything from callouts, citations, styled blocks, forms, embeds, spoilers, etc.
311+
You can use this with some more code to match your specific needs,
312+
to allow for anything from callouts,
313+
citations,
314+
styled blocks,
315+
forms,
316+
embeds,
317+
spoilers,
318+
etc.
293319
[Traverse the tree][unifiedjs-tree-traversal] to change directives to whatever
294320
you please.
295321

@@ -322,7 +348,8 @@ Its content model is also **[phrasing][github-mdast-phrasing-content]**
322348
content.
323349
It includes the mixin **[Directive][syntax-tree-mixin-directive]**.
324350

325-
For example, the following Markdown:
351+
For example,
352+
the following Markdown:
326353

327354
```markdown
328355
:name[Label]{#x.y.z key=value}
@@ -355,7 +382,8 @@ It can be used where **[flow][github-mdast-flow-content]** content is expected.
355382
Its content model is **[phrasing][github-mdast-phrasing-content]** content.
356383
It includes the mixin **[Directive][syntax-tree-mixin-directive]**.
357384

358-
For example, the following Markdown:
385+
For example,
386+
the following Markdown:
359387

360388
```markdown
361389
::youtube[Label]{v=123}
@@ -388,10 +416,13 @@ It can be used where **[flow][github-mdast-flow-content]** content is expected.
388416
Its content model is also **[flow][github-mdast-flow-content]** content.
389417
It includes the mixin **[Directive][syntax-tree-mixin-directive]**.
390418

391-
The phrasing in the label is, when available, added as a paragraph with a
392-
`directiveLabel: true` field, as the head of its content.
419+
The phrasing in the label is,
420+
when available,
421+
added as a paragraph with a `directiveLabel: true` field,
422+
as the head of its content.
393423

394-
For example, the following Markdown:
424+
For example,
425+
the following Markdown:
395426

396427
```markdown
397428
:::spoiler[Open at your own peril]
@@ -442,25 +473,29 @@ The `name` field must be present and represents an identifier of an extension.
442473
The `attributes` field represents information associated with the node.
443474
The value of the `attributes` field implements the **Attributes** interface.
444475

445-
In the **Attributes** interface, every field must be an `AttributeName` and
446-
every value an `AttributeValue`.
447-
The fields and values can be anything: there are no semantics (such as by HTML
448-
or hast).
476+
In the **Attributes** interface,
477+
every field must be an `AttributeName` and every value an `AttributeValue`.
478+
The fields and values can be anything:
479+
there are no semantics (such as by HTML or hast).
449480

450-
> In JSON, the value `null` must be treated as if the attribute was not
451-
> included.
452-
> In JavaScript, both `null` and `undefined` must be similarly ignored.
481+
> In JSON,
482+
> the value `null` must be treated as if the attribute was not included.
483+
> In JavaScript,
484+
> both `null` and `undefined` must be similarly ignored.
453485
454486
## Types
455487

456488
This package is fully typed with [TypeScript][].
457489
It exports the additional types [`ContainerDirective`][api-container-directive],
458-
[`Directives`][api-directives], [`LeafDirective`][api-leaf-directive], and
490+
[`Directives`][api-directives],
491+
[`LeafDirective`][api-leaf-directive],
492+
and
459493
[`TextDirective`][api-text-directive].
460494

461495
It also registers the node types with `@types/mdast`.
462-
If you’re working with the syntax tree, make sure to import this utility
463-
somewhere in your types, as that registers the new node types in the tree.
496+
If you’re working with the syntax tree,
497+
make sure to import this utility somewhere in your types,
498+
as that registers the new node types in the tree.
464499

465500
```js
466501
/**
@@ -483,9 +518,10 @@ visit(tree, function (node) {
483518
Projects maintained by the unified collective are compatible with maintained
484519
versions of Node.js.
485520

486-
When we cut a new major release, we drop support for unmaintained versions of
487-
Node.
488-
This means we try to keep the current release line, `mdast-util-directive@^3`,
521+
When we cut a new major release,
522+
we drop support for unmaintained versions of Node.
523+
This means we try to keep the current release line,
524+
`mdast-util-directive@3`,
489525
compatible with Node.js 16.
490526

491527
This utility works with `mdast-util-from-markdown` version 2+ and
@@ -507,8 +543,9 @@ for ways to get started.
507543
See [`support.md`][health-support] for ways to get help.
508544

509545
This project has a [code of conduct][health-coc].
510-
By interacting with this repository, organization, or community you agree to
511-
abide by its terms.
546+
By interacting with this repository,
547+
organization,
548+
or community you agree to abide by its terms.
512549

513550
## License
514551

0 commit comments

Comments
 (0)