syn-rsx
syn-powered parser for JSX-like TokenStreams, aka RSX. The parsed result is a nested Node
structure, similar to the browser DOM, where node name and value are syn expressions to support building proc macros.
use quote;
use parse2;
let tokens = quote! ;
let nodes = parse2.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
Features
-
Not opinionated
Every tag or attribute name is valid
-
Text nodes
Support for unquoted text is planned (currently requires Rust nightly)
"String literal"
-
Node names separated by dash or colon
-
Node names as mod style path
-
Node names with reserved keywords
-
Attribute values can be any valid syn expression without requiring braces
-
Braced blocks are parsed as arbitrary Rust code
{ let block = "in node position"; }
-
Customization
A
ParserConfig
to customize parsing behavior is available, so if you have slightly different requirements for parsing and it's not yet customizable feel free to open an issue or pull request to extend the configuration.