JSON schema for unist/mdast #61
-
Heya, Is there a "ratified" JSON schema for unist (and also mdast)? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Something along the lines of this is what I came up with? {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Syntactic unit in unist syntax trees.",
"type": "object",
"$defs": {
"point": {
"description": "A point represents one place in a source file.",
"type": "object",
"required": ["line", "column"],
"properties": {
"line": {
"description": "The line number of the point.",
"type": "integer",
"minimum": 1
},
"column": {
"description": "The column number of the point.",
"type": "integer",
"minimum": 1
},
"offset": {
"description": "The offset of the point.",
"type": "integer",
"minimum": 0
}
}
},
"position": {
"description": "A position represents the location of a node in a source file.",
"type": "object",
"required": ["start", "end"],
"properties": {
"start": {
"description": "The start position of the position.",
"$ref": "#/definitions/point"
},
"end": {
"description": "The end position of the position.",
"$ref": "#/definitions/point"
},
"indent": {
"description": "The indentation of the position.",
"type": "integer",
"minimum": 0
}
}
}
},
"required": ["type"],
"properties": {
"type": {
"description": "The type of the node.",
"type": "string"
},
"position": {
"$ref": "#/definitions/position"
},
"data": {
"description": "Information associated by the ecosystem with the node.",
"type": "object"
},
"children": {
"description": "The children of a Parent node.",
"type": "array",
"items": {
"$ref": "#"
}
},
"value": {
"description": "The value of a Literal node."
}
}
} |
Beta Was this translation helpful? Give feedback.
-
There are some assertion libraries that check that various syntax trees have expected structure:
There are also standards documents for each:
I don't know if there an official schema 🤔 The one you shared @chrisjsewell looks about right. |
Beta Was this translation helpful? Give feedback.
There are some assertion libraries that check that various syntax trees have expected structure:
There are also standards documents for each:
I don't know if there an official schema 🤔
/cc @remcohaszing I know you worked on JSON schemas for configuration files, did you also create some for the trees themselves?
The one you shared @chrisjsewell looks about …