mirror of https://github.com/kdl-org/kdl-rs.git
|
|
||
|---|---|---|
| .github | ||
| examples | ||
| src | ||
| .editorconfig | ||
| .gitignore | ||
| CHANGELOG.md | ||
| CODE_OF_CONDUCT.md | ||
| Cargo.toml | ||
| LICENSE | ||
| Makefile.toml | ||
| README.md | ||
| cliff.toml | ||
README.md
kdl is a "document-oriented" parser and API. That means that, unlike
serde-based implementations, it's meant to preserve formatting when editing,
as well as inserting values with custom formatting. This is useful when
working with human-maintained KDL files.
You can think of this crate as
toml_edit, but for KDL.
Example
use kdl::KdlDocument;
let doc: KdlDocument = r#"
hello 1 2 3
world prop="value" {
child 1
child 2
}
"#.parse().expect("failed to parse KDL");
assert_eq!(doc.get_args("hello"), vec![&1.into(), &2.into(), &3.into()]);
assert_eq!(doc.get("world").map(|node| &node["prop"]), Some(&"value".into()));
License
The code in this repository is covered by the Apache-2.0 License.