raffia

Crates.ioraffia
lib.rsraffia
version0.9.1
sourcesrc
created_at2022-09-25 01:42:10.31061
updated_at2024-08-14 16:23:42.577932
descriptionOne parser for CSS/SCSS/Sass/Less.
homepage
repositoryhttps://github.com/g-plane/raffia
max_upload_size
id673396
size570,010
Pig Fang (g-plane)

documentation

README

Raffia

Crates.io docs.rs

Raffia is a parser which can parse CSS, SCSS, Sass (indented syntax) and Less. However, it won't compile SCSS, Sass or Less to CSS.

๐Ÿงช Playground

There is an online playground for inspecting AST. Visit: https://raffia-play.vercel.app/.

๐Ÿญ Example

use raffia::{ast::Stylesheet, Parser, Syntax};

let mut parser = Parser::new("a { color: green }", Syntax::Css);
let ast = parser.parse::<Stylesheet>().unwrap();
println!("{:#?}", ast);

You can find more examples in the examples directory.

For detailed usage, check out docs.rs.

โŒ› Benchmark

You can compare performance with other parsers in benchmark.

First, you need to setup Rust and clone this repository. You also need to install cargo-criterion by running cargo install cargo-criterion.

Then, copy some CSS files to bench_data directory. You need to create that directory by yourself.

Now you can run benchmark by running cargo criterion.

โœจ Credit

Tests come from:

๐Ÿ“œ License

MIT License

Copyright (c) 2022-present Pig Fang

Commit count: 738

cargo fmt