Lossless YAML Parser and Editor
A Rust library for parsing and editing YAML files while preserving all whitespace, comments, and formatting. Built with the rowan library for lossless syntax trees.
Features
- Lossless parsing: Preserves all whitespace, comments, and original formatting
- Editing support: Modify YAML structures while maintaining formatting
- Error recovery: Continues parsing even with syntax errors
- Position tracking: Detailed error locations for debugging
Example
use Yaml;
use FromStr;
let input = r#"
# Configuration file
name: my-project
version: 1.0.0
dependencies:
- serde
- tokio
features:
default: []
full:
- "serde"
- "tokio"
"#;
let mut yaml = from_str.unwrap;
// Access documents
if let Some = yaml.document
// The original formatting is preserved
println!;