Expand description
§Neutron Engine
A lightweight markup parser for the Neutron styling language (.nt). Provides fast, zero-dependency parsing of XML-like tags with inline style declarations.
§Example
use neutron_engine::{parse_tag, parse_attributes, parse_style, normalize_decl, Attribute, StyleDecl};
let tag = r#"<Container style="b:#000; w:fill" id="Main">"#;
if let Some((name, attrs_text)) = parse_tag(tag) {
println!("Tag: {}", name);
let mut attrs = [Attribute { name: "", value: "" }; 12];
let attr_count = parse_attributes(attrs_text, &mut attrs);
for attr in &attrs[..attr_count] {
if attr.name == "style" {
let mut styles = [StyleDecl { name: "", value: "" }; 16];
let style_count = parse_style(attr.value, &mut styles);
for style in &styles[..style_count] {
let prop = normalize_decl(*style);
println!("Style: {:?}", prop);
}
}
}
}Modules§
Structs§
- Attribute
- Represents an attribute with name and value
- Style
Decl - Represents a style declaration with name and value
Enums§
- Style
Prop - Normalized style property enum
Functions§
- normalize_
decl - Normalize a style declaration into a typed StyleProp
- parse_
attributes - Parse attributes from a string into an array of Attribute structs
- parse_
neutron - Parse a complete Neutron document and print the parsed structure
- parse_
neutron_ file - Read a Neutron file and parse it
- parse_
style - Parse style declarations from a string
- parse_
tag - Parse a tag string into tag name and attributes text