pub fn plugin() -> PluginExpand description
The css grammar as an engine plugin, named css: Css in the canonical
port. Its options are an Options bag (Options::to_value).
It installs the grammar’s rules (each alternate tagged with the group
css), the canonical option overrides and the cssToken matcher. Use it
on jsonic, as make does and the canonical port documents; on a bare
engine it gives the same results.
The engine’s own parse returns the tree as an engine tabnas::Value,
the canonical port’s plain objects: equal to them value for value, though
the engine writes a whole number as 1.0 in JSON, a position.end that
was never recorded is absent rather than an undefined key, and an error’s
column counts Unicode scalars as the engine’s always do, where this
crate’s Error counts UTF-16 code units (convert with Error::from).
That tree is bounded at TREE_RULE_DEPTH open rules. Css::parse has
none of these differences and no limit. With the engine’s recovery on,
the parse returns a partial stylesheet, which is not always the
canonical port’s: see doc/concepts.md.
let mut parser = tabnas_css::tabnas_jsonic::make();
parser.use_plugin(tabnas_css::plugin(), None).unwrap();
let ast = parser.parse("a { color: red }").unwrap();
assert_eq!(
ast.to_json().to_string(),
r#"{"type":"stylesheet","rules":[{"type":"rule","selectors":["a"],"declarations":[{"type":"declaration","property":"color","value":"red"}]}]}"#
);