oxc-css-parser parses CSS, SCSS, Sass, and Less. It produces an AST and does not compile preprocessor syntax to CSS.
use oxc_css_parser::{Allocator, Parser, Syntax, ast::Stylesheet};
let allocator = Allocator::default();
let mut parser = Parser::new(&allocator, "a { color: green }", Syntax::Css);
let ast = parser.parse::<Stylesheet>().unwrap();
println!("{:#?}", ast);More examples are available in examples.
For detailed API documentation, see docs.rs.
The benchmark suite compares parser performance against other CSS parsers.
Install cargo-criterion, then run the checked-in fixture benchmark:
cargo install cargo-criterion
cargo criterionTo benchmark custom inputs, add CSS, SCSS, Sass, or Less files to a local bench_data
directory. When bench_data contains supported files, it is used instead of the
checked-in fixtures.
Tests come from:
MIT License