Skip to content

Commit 1794971

Browse files
committed
Add sections on possible values
This fix specifies which values are allowed in Unist. Closes GH-4.
1 parent 15bf170 commit 1794971

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

readme.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,22 @@ See [**nlcst**][nlcst] for more information on **retext** nodes,
2020
[**mdast**][mdast] for information on **remark** nodes, and
2121
[`hast#nodes`][hast-nodes] for information on **hast** nodes.
2222

23+
Subsets of Unist can define new properties on new nodes, and plug-ins
24+
and utilities can define new [`data`][data] properties on nodes. But,
25+
the values on those properties **must** be JSON values: `string`,
26+
`number`, `object`, `array`, `true`, `false`, or `null`.
27+
2328
### `Node`
2429

2530
Node represents any unit in the Unist hierarchy. It is an abstract
2631
class. Interfaces inheriting from **Node** must have a `type` property,
2732
and may have `data` or `location` properties. `type`s are defined by
2833
their namespace.
2934

35+
Subsets of Unist are allowed to define properties on interfaces which
36+
subclass Unist’s abstract interfaces. For example, [mdast][] defines
37+
a `link` node (subclassing [Parent][]) with a `url` property.
38+
3039
```idl
3140
interface Node {
3241
type: string;
@@ -37,9 +46,10 @@ interface Node {
3746

3847
#### `Data`
3948

40-
Data represents data associated with any node. Data is a scope for plug-ins
41-
to store any information. Its only limitation being that each property should
42-
by `stringify`able: not throw when passed to `JSON.stringify()`.
49+
Data represents data associated with any node. `Data` is a scope for
50+
plug-ins to store any information. For example, [`remark-html`][remark-html]
51+
uses `htmlAttributes` to let other plug-ins specify attributes added
52+
to the compiled HTML element.
4353

4454
```idl
4555
interface Data { }
@@ -175,3 +185,9 @@ A list of **VFile**-related utilities can be found at [**vfile**][vfile].
175185
[hast-nodes]: https://github.com/wooorm/hast#nodes
176186

177187
[vfile]: https://github.com/wooorm/vfile
188+
189+
[remark-html]: https://github.com/wooorm/remark-html
190+
191+
[parent]: #parent
192+
193+
[data]: #data

0 commit comments

Comments
 (0)