@@ -20,13 +20,22 @@ See [**nlcst**][nlcst] for more information on **retext** nodes,
20
20
[ ** mdast** ] [ mdast ] for information on ** remark** nodes, and
21
21
[ ` hast#nodes ` ] [ hast-nodes ] for information on ** hast** nodes.
22
22
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
+
23
28
### ` Node `
24
29
25
30
Node represents any unit in the Unist hierarchy. It is an abstract
26
31
class. Interfaces inheriting from ** Node** must have a ` type ` property,
27
32
and may have ` data ` or ` location ` properties. ` type ` s are defined by
28
33
their namespace.
29
34
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
+
30
39
``` idl
31
40
interface Node {
32
41
type: string;
@@ -37,9 +46,10 @@ interface Node {
37
46
38
47
#### ` Data `
39
48
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.
43
53
44
54
``` idl
45
55
interface Data { }
@@ -175,3 +185,9 @@ A list of **VFile**-related utilities can be found at [**vfile**][vfile].
175
185
[ hast-nodes ] : https://github.com/wooorm/hast#nodes
176
186
177
187
[ 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