Crates.io | marked-yaml |
lib.rs | marked-yaml |
version | 0.7.1 |
source | src |
created_at | 2020-01-31 11:24:57.71964 |
updated_at | 2024-07-01 17:07:46.087381 |
description | A simplified YAML structure with provenance spans |
homepage | https://github.com/kinnison/marked-yaml/ |
repository | https://github.com/kinnison/marked-yaml.git |
max_upload_size | |
id | 203602 |
size | 128,487 |
This library builds atop yaml-rust2
to provide a YAML AST which
includes the marks for where the YAML data comes from. It explicitly operates
at a low level, providing only the base safe YAML types (i.e. the vanilla
tags tag:yaml.org,2002:seq
, tag:yaml.org,2002:map
, and tag:yaml.org,2002:str
)
The subset of YAML which is supported is quite deliberately limited in order that users of this crate will implicitly discourage complex use of YAML which is harder to manage user expectations with. As an example, the mapping type in this crate explicitly only permits scalars as keys, and since all scalars are treated as strings, mappings always have string keys.
The primary value of this kind of representation of YAML data is to allow applications which want to be very explicit about where input came from an opportunity to do this in a way which normal YAML parsers do not allow.
Currently this library only supports loading YAML from strings, but this is sufficient for most users' purposes. We would not recommend an un-streamed processing engine for massive data anyway.
To load some YAML you simply need to:
let node = marked_yaml::parse_yaml(0, r#"
toplevel: must be a mapping
but:
- it
- may
- contain lists
and:
mappings: are permitted
as: sub-mappings
"#);
assert!(node.is_ok());
Parsing a valid YAML file may fail because marked_yaml
adds some
additional constraints:
In addition, you can convert between marked_yaml::Node
and yaml_rust::Yaml
though doing so will not give you any useful markers.