1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! # YAMP - Yet Another Minimal Parser
//!
//! A lightweight, efficient YAML parser that treats all scalar values as strings,
//! avoiding YAML's numerous type-related pitfalls.
//!
//! ## Features
//!
//! - All scalar values are strings (no implicit type conversion)
//! - Supports basic YAML structures (objects, arrays, scalars)
//! - Preserves comments during parsing
//! - Supports multiline strings (literal `|` and folded `>`)
//! - Zero dependencies
//! - Predictable, secure behavior
//!
//! ## Example
//!
//! ```rust
//! use yamp::{parse, emit, YamlValue};
//! use std::borrow::Cow;
//!
//! let yaml = "name: John\nage: 30";
//! let parsed = parse(yaml).expect("Failed to parse");
//!
//! // Using the new helper methods for cleaner access
//! if let Some(name) = parsed.get("name").and_then(|n| n.as_str()) {
//! assert_eq!(name, "John");
//! }
//!
//! // Or using the traditional approach
//! if let YamlValue::Object(map) = &parsed.value {
//! let age = &map.get(&Cow::Borrowed("age")).unwrap().value;
//! // Note: age is a string "30", not a number
//! assert_eq!(age, &YamlValue::String(Cow::Borrowed("30")));
//! }
//!
//! let output = emit(&parsed);
//! ```
pub use ;
use Emitter;
use Parser;
/// Parse a YAML string into a `YamlNode`.
///
/// All scalar values are parsed as strings. No type inference is performed.
///
/// # Example
///
/// ```rust
/// use yamp::parse;
///
/// let yaml = "name: John\nage: 30";
/// let parsed = parse(yaml).expect("Failed to parse");
/// ```
/// Emit a `YamlNode` back to a YAML string.
///
/// Preserves comments and automatically uses multiline string format
/// for values containing newlines.
///
/// # Example
///
/// ```rust
/// use yamp::{parse, emit};
///
/// let yaml = "name: John";
/// let parsed = parse(yaml).expect("Failed to parse");
/// let output = emit(&parsed);
/// assert!(output.contains("name: John"));
/// ```