|
| 1 | +#  |
| 2 | + |
| 3 | +**Unist** (universal syntax tree) is the combination of two project, and more |
| 4 | +to come, which are the summation of at least [two](https://github.com/wooorm/retext/commit/8fcb1ff4874d1891791280d63125d27ed29b58a8) |
| 5 | +[years](https://github.com/wooorm/mdast/commit/19585b8) of my work and the |
| 6 | +current epitome of that. |
| 7 | + |
| 8 | +It’s basically a system for processing input: parsing it into a syntax tree, |
| 9 | +transformation by plug-ins, and compiling the syntax tree to something else. |
| 10 | + |
| 11 | +This document explains some terminology relating to |
| 12 | +[**retext**](https://github.com/wooorm/retext), |
| 13 | +[**mdast**](https://github.com/wooorm/mdast), and their related projects. |
| 14 | + |
| 15 | +## Unist nodes |
| 16 | + |
| 17 | +**Unist nodes**: |
| 18 | + |
| 19 | +* must have a `type` property set to a to its namespace semantic |
| 20 | + `string`; |
| 21 | + |
| 22 | +* must have either a `value` property set to a `string` or a `children` |
| 23 | + property set to an array of one or more `Unist` nodes; |
| 24 | + |
| 25 | +* may have a `data` property set to a `JSON.stringify`able object; |
| 26 | + |
| 27 | +* may have an `attributes` property set to a an object of `String`ifyable |
| 28 | + values; |
| 29 | + |
| 30 | +* may have a `position` property set to a an object containing `start` and |
| 31 | + `end`, both of which contain an object with `line` and `column` set |
| 32 | + to an integer referencing their respective (1-based) line and column |
| 33 | + in the input file. Both may have an `offset` property set to its |
| 34 | + index from the beginning of the input. If a node represents something not |
| 35 | + available in the original input, it must not have a `position`. |
| 36 | + |
| 37 | +See [**nlcst**](https://github.com/wooorm/nlcst) for more information |
| 38 | +on **retext** nodes, and [`mdast/doc/nodes.md`](https://github.com/wooorm/mdast/blob/master/doc/nodes.md) |
| 39 | +for information on **mdast** nodes. |
| 40 | + |
| 41 | +## Unist files |
| 42 | + |
| 43 | +**Unist files** are virtual files (such as [**vfile**](https://github.com/wooorm/vfile)) |
| 44 | +representing content at a certain location. They are not limited to existing |
| 45 | +files. Neither are they limited to the file-system only. |
| 46 | + |
| 47 | +## Unist utilities |
| 48 | + |
| 49 | +...are function which work with **unist nodes** or **unist files**, agnostic |
| 50 | +of either **mdast** or **retext**. |
0 commit comments