https://github.com/t1/yaml
A YAML DOM
https://github.com/t1/yaml
yaml yaml-parser
Last synced: 6 months ago
JSON representation
A YAML DOM
- Host: GitHub
- URL: https://github.com/t1/yaml
- Owner: t1
- License: apache-2.0
- Created: 2018-05-03T03:57:37.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-09-02T05:44:24.000Z (almost 4 years ago)
- Last Synced: 2025-01-19T09:32:10.634Z (over 1 year ago)
- Topics: yaml, yaml-parser
- Language: Kotlin
- Homepage:
- Size: 463 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About
We _love_ [YAML](http://yaml.org). It's more compact than JSON and more powerful than XML... and that's saying a lot for both comparisons!
This project is not only a fully compliant YAML 1.2 implementation, it also adds some important features:
1. A **DOM** (document object model) so a document can be manipulated in a generic manner, e.g. for use-cases with dynamic keys, so you can't bind them to fixed keys.
1. **document-first**: many documents are carefully designed, include comments, structuring empty lines, sorted mappings, etc.
The load-dump cycle as defined in the YAML spec looses all this helpful, albeit technically unnecessary information.
1. A **schema**, not for verification (that's actually mostly boring), but for documentation!
This includes examples, and allows generic YAML editors to support specific document types.
Documents may want to adhere to more than one schema, so we would also need **namespaces**,
but that may be something for the future.
# Status and Plan
* **DOM**: beta - missing mainly documentation and a more formal specification
* **Load-Dump**: alpha - simple documents may work
* **Schema**: ideas only
# DOM
## Comments
Comments are preserved, before documents, in documents, and after the document-end-marker (suffix).
## Canonical
`canonicalize` does:
* Adds YAML directive
* Removes comments
* Adds tags
* Removes documents without a node
* Concatenates multi-line literals
## Normalization
We do as little normalizations as possible, but some are:
* A document always ends with a newline character.
* New lines of scalars are indented at least as much as the appropriate for the current nesting,
i.e. the second and subsequent lines of a scalar value in a block mapping is indented by two.