2
2
3
3
** Uni** versal ** S** yntax ** T** ree.
4
4
5
- ** *
5
+ * * *
6
6
7
7
** Unist** is the combination of three syntax trees, and more to come:
8
8
[ ** mdast** ] [ mdast ] with [ ** remark** ] [ remark ] for markdown, [ ** nlcst** ] [ nlcst ]
@@ -12,8 +12,9 @@ with [**retext**][retext] for prose, and [**hast**][hast] with
12
12
This document explains some terminology relating to [ ** unified** ] [ unified ] and
13
13
[ ** vfile** ] [ vfile ] as well.
14
14
15
- This document may not be released. See [ releases] [ ] for released
16
- documents. The latest released version is [ ` 1.1.0 ` ] ( https://github.com/syntax-tree/unist/releases/tag/1.1.0 ) .
15
+ This document may not be released.
16
+ See [ releases] [ ] for released documents.
17
+ The latest released version is [ ` 1.1.0 ` ] ( https://github.com/syntax-tree/unist/releases/tag/1.1.0 ) .
17
18
18
19
## Table of Contents
19
20
@@ -31,29 +32,30 @@ documents. The latest released version is [`1.1.0`](https://github.com/syntax-tr
31
32
32
33
## Unist nodes
33
34
34
- Subsets of Unist can define new properties on new nodes, and plug-ins
35
- and utilities can define new [ ` data ` ] [ data ] properties on nodes. But,
36
- the values on those properties ** must** be JSON values: ` string ` ,
37
- ` number ` , ` object ` , ` array ` , ` true ` , ` false ` , or ` null ` . This means
38
- that the syntax tree should be able to be converted to and from JSON
39
- and produce the same tree. For example, in JavaScript, a tree should
40
- be able to be passed through ` JSON.parse(JSON.stringify(tree)) ` and
41
- result in the same values.
35
+ Subsets of Unist can define new properties on new nodes, and plug-ins and
36
+ utilities can define new [ ` data ` ] [ data ] properties on nodes.
37
+ But, the values on those properties ** must** be JSON values: ` string ` ,
38
+ ` number ` , ` object ` , ` array ` , ` true ` , ` false ` , or ` null ` .
39
+ This means that the syntax tree should be able to be converted to and from JSON
40
+ and produce the same tree.
41
+ For example, in JavaScript, a tree should be able to be passed through
42
+ ` JSON.parse(JSON.stringify(tree)) ` and result in the same values.
42
43
43
44
See [ ** nlcst** ] [ nlcst ] for more information on ** retext** nodes,
44
45
[ ** mdast** ] [ mdast ] for information on ** remark** nodes, and
45
46
[ ** hast** ] [ hast ] for information on ** rehype** nodes.
46
47
47
48
### ` Node `
48
49
49
- A Node represents any unit in the Unist hierarchy. It is an abstract
50
- interface. Interfaces extending ** Node** must have a ` type ` property,
51
- and may have ` data ` or ` position ` properties. The value of node [ type] [ ] s
52
- are defined by their namespace.
50
+ A Node represents any unit in the Unist hierarchy.
51
+ It is an abstract interface.
52
+ Interfaces extending ** Node** must have a ` type ` property, and may have
53
+ ` data ` or ` position ` properties.
54
+ The value of node [ type] [ ] s are defined by their namespace.
53
55
54
- Subsets of Unist are allowed to define properties on interfaces which
55
- extend Unist’s abstract interfaces. For example, [ mdast ] [ ] defines
56
- ** Link** ([ Parent] [ ] ) with a ` url ` property.
56
+ Subsets of Unist are allowed to define properties on interfaces which extend
57
+ Unist’s abstract interfaces.
58
+ For example, [ mdast ] [ ] defines ** Link** ([ Parent] [ ] ) with a ` url ` property.
57
59
58
60
``` idl
59
61
interface Node {
@@ -65,10 +67,10 @@ interface Node {
65
67
66
68
#### ` Data `
67
69
68
- Data represents data associated with any node. ` Data ` is a scope for
69
- plug-ins to store any information. For example, [ ` remark-html ` ] [ remark-html ]
70
- uses ` hProperties ` to let other plug-ins specify properties added to the
71
- compiled HTML element.
70
+ Data represents data associated with any node.
71
+ ` Data ` is a scope for plug-ins to store any information.
72
+ For example, [ ` remark-html ` ] [ remark-html ] uses ` hProperties ` to let other
73
+ plug-ins specify properties added to the compiled HTML element.
72
74
73
75
``` idl
74
76
interface Data { }
@@ -77,12 +79,14 @@ interface Data { }
77
79
#### ` Position `
78
80
79
81
** Position** references a range consisting of two points in a [ Unist
80
- file] [ file ] . ** Position** consists of a ` start ` and ` end ` point.
82
+ file] [ file ] .
83
+ ** Position** consists of a ` start ` and ` end ` point.
81
84
And, if relevant, an ` indent ` property.
82
85
83
86
When the value represented by a node is not present in the document
84
- corresponding to the syntax tree at the time of reading, it must not
85
- have positional information. These nodes are said to be _ generated_ .
87
+ corresponding to the syntax tree at the time of reading, it must not have
88
+ positional information.
89
+ These nodes are said to be _ generated_ .
86
90
87
91
``` idl
88
92
interface Position {
@@ -94,9 +98,9 @@ interface Position {
94
98
95
99
#### ` Point `
96
100
97
- ** Point** references a point consisting of two indices in a
98
- [ Unist file ] [ file ] : ` line ` and ` column ` , set to 1-based integers. An
99
- ` offset ` (0-based) may be used.
101
+ ** Point** references a point consisting of two indices in a [ Unist file ] [ file ] :
102
+ ` line ` and ` column ` , set to 1-based integers.
103
+ An ` offset ` (0-based) may be used.
100
104
101
105
``` idl
102
106
interface Point {
@@ -108,8 +112,8 @@ interface Point {
108
112
109
113
### ` Parent `
110
114
111
- Nodes containing other nodes (said to be ** children** ) extend the
112
- abstract interface ** Parent** ([ ** Node** ] ( #node ) ).
115
+ Nodes containing other nodes (said to be ** children** ) extend the abstract
116
+ interface ** Parent** ([ ** Node** ] ( #node ) ).
113
117
114
118
``` idl
115
119
interface Parent <: Node {
@@ -155,8 +159,7 @@ Node X is a **sibling** of node Y, if X and Y have the same
155
159
The ** previous sibling** of a [ child] [ ] is its ** sibling** at its [ index] [ ]
156
160
minus 1.
157
161
158
- The ** next sibling** of a [ child] [ ] is its ** sibling** at its [ index] [ ]
159
- plus 1.
162
+ The ** next sibling** of a [ child] [ ] is its ** sibling** at its [ index] [ ] plus 1.
160
163
161
164
###### Root
162
165
@@ -193,21 +196,21 @@ The **type** of a node is the value of its `type` property.
193
196
194
197
## Unist files
195
198
196
- ** Unist files** are virtual files (such as [ ** vfile** ] [ vfile ] )
197
- representing documents at a certain location. They are not limited to
198
- existing files, nor to the file-system.
199
+ ** Unist files** are virtual files (such as [ ** vfile** ] [ vfile ] ) representing
200
+ documents at a certain location.
201
+ They are not limited to existing files, nor to the file-system.
199
202
200
203
## Unist utilities
201
204
202
- ** Unist utilities** are functions which work with ** unist nodes** ,
203
- agnostic of ** remark** , ** retext** , or ** rehype** .
205
+ ** Unist utilities** are functions which work with ** unist nodes** , agnostic of
206
+ ** remark** , ** retext** , or ** rehype** .
204
207
205
208
A list of ** vfile** -related utilities can be found at [ ** vfile** ] [ vfile ] .
206
209
207
210
### List of Utilities
208
211
209
212
* [ ` unist-util-assert ` ] ( https://github.com/syntax-tree/unist-util-assert )
210
- — Assert Unist nodes
213
+ — Assert nodes
211
214
* [ ` unist-util-filter ` ] ( https://github.com/eush77/unist-util-filter )
212
215
— Create a new tree with all nodes that pass the given function
213
216
* [ ` unist-util-find ` ] ( https://github.com/blahah/unist-util-find )
@@ -241,9 +244,9 @@ A list of **vfile**-related utilities can be found at [**vfile**][vfile].
241
244
* [ ` unist-util-position ` ] ( https://github.com/syntax-tree/unist-util-position )
242
245
— Get positional info of nodes
243
246
* [ ` unist-util-remove ` ] ( https://github.com/eush77/unist-util-remove )
244
- — Remove nodes from Unist trees
247
+ — Remove nodes from trees
245
248
* [ ` unist-util-remove-position ` ] ( https://github.com/syntax-tree/unist-util-remove-position )
246
- — Remove positional info from a unist tree
249
+ — Remove positional info from trees
247
250
* [ ` unist-util-select ` ] ( https://github.com/eush77/unist-util-select )
248
251
— Select nodes with CSS-like selectors
249
252
* [ ` unist-util-source ` ] ( https://github.com/syntax-tree/unist-util-source )
@@ -261,21 +264,24 @@ A list of **vfile**-related utilities can be found at [**vfile**][vfile].
261
264
* [ ` unist-builder ` ] ( https://github.com/eush77/unist-builder )
262
265
— Helper for creating trees
263
266
* [ ` unist-builder-blueprint ` ] ( https://github.com/eush77/unist-builder-blueprint )
264
- — Convert Unist trees to unist-builder notation
267
+ — Convert Unist trees to ` unist-builder ` notation
265
268
266
269
## Contribute
267
270
268
- ** unist** is built by people just like you! Check out
269
- [ ` contributing.md ` ] [ contributing ] for ways to get started.
271
+ ** unist** is built by people just like you!
272
+ Check out [ ` contributing.md ` ] [ contributing ] for ways to get started.
270
273
271
- This project has a [ Code of Conduct] [ coc ] . By interacting with this repository,
272
- organisation, or community you agree to abide by its terms.
274
+ This project has a [ Code of Conduct] [ coc ] .
275
+ By interacting with this repository, organisation, or community you agree to
276
+ abide by its terms.
273
277
274
- Want to chat with the community and contributors? Join us in [ Gitter] [ chat ] !
278
+ Want to chat with the community and contributors?
279
+ Join us in [ Gitter] [ chat ] !
275
280
276
- Have an idea for a cool new utility or tool? That’s great! If you want
277
- feedback, help, or just to share it with the world you can do so by creating
278
- an issue in the [ ` syntax-tree/ideas ` ] [ ideas ] repository!
281
+ Have an idea for a cool new utility or tool?
282
+ That’s great!
283
+ If you want feedback, help, or just to share it with the world you can do so by
284
+ creating an issue in the [ ` syntax-tree/ideas ` ] [ ideas ] repository!
279
285
280
286
## Acknowledgments
281
287
0 commit comments