Skip to content

Add sections on possible values #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,26 @@ See [**nlcst**][nlcst] for more information on **retext** nodes,
[**mdast**][mdast] for information on **remark** nodes, and
[`hast#nodes`][hast-nodes] for information on **hast** nodes.

Subsets of Unist can define new properties on new nodes, and plug-ins
and utilities can define new [`data`][data] properties on nodes. But,
the values on those properties **must** be JSON values: `string`,
`number`, `object`, `array`, `true`, `false`, or `null`. This means
that the syntax tree should be able to be converted to and from JSON
and produce the same tree. For example, in JavaScript, a tree should
be able to be passed through `JSON.parse(JSON.stringify(tree))` and
result in the same values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eush77 I clarified your questions, how about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wooorm Yeah, I think it's good. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

### `Node`

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

Subsets of Unist are allowed to define properties on interfaces which
subclass Unist’s abstract interfaces. For example, [mdast][] defines
a `link` node (subclassing [Parent][]) with a `url` property.

```idl
interface Node {
type: string;
Expand All @@ -37,9 +50,10 @@ interface Node {

#### `Data`

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

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

[vfile]: https://github.com/wooorm/vfile

[remark-html]: https://github.com/wooorm/remark-html

[parent]: #parent

[data]: #data