pub fn parse_preserving(input: &str) -> Result<Document>Expand description
Create a NOML value using a convenient macro syntax
§Example
use noml::{noml_value, Value};
let config = noml_value!({
"name" => "my-app",
"version" => "1.0.0",
"features" => ["parsing", "validation"],
"server" => {
"host" => "localhost",
"port" => 8080
}
});
assert_eq!(config.get("server.port").unwrap().as_integer().unwrap(), 8080);§Format Preservation API
NOML provides unique format preservation capabilities that maintain the exact formatting, comments, and style of the original file during parsing and editing. This makes NOML the first configuration language with true format preservation.
Parse NOML from a string with full format preservation.
Unlike the regular parse() function, this preserves all formatting metadata
including whitespace, comments, indentation style, and quote styles, enabling
perfect round-trip editing.
§Examples
use noml::{parse_preserving, serialize_document};
let source = r#"# This is a comment
name = "my-app" # Inline comment
version = "1.0.0"
[server]
host = "localhost"
port = 8080
"#;
// Parse with format preservation
let document = parse_preserving(source)?;
// Serialize back to string - preserves exact formatting
let output = serialize_document(&document)?;
// Note: exact formatting preservation requires enhanced lexer implementation