17 unstable releases (8 breaking)

0.9.1 Aug 14, 2024
0.8.2 Aug 6, 2024
0.8.0 Jul 27, 2024
0.7.2 Oct 21, 2023
0.1.0 Sep 25, 2022

#434 in Web programming

Download history 742/week @ 2024-08-19 613/week @ 2024-08-26 978/week @ 2024-09-02 1094/week @ 2024-09-09 824/week @ 2024-09-16 842/week @ 2024-09-23 862/week @ 2024-09-30 1537/week @ 2024-10-07 1457/week @ 2024-10-14 1219/week @ 2024-10-21 1473/week @ 2024-10-28 1151/week @ 2024-11-04 864/week @ 2024-11-11 826/week @ 2024-11-18 1099/week @ 2024-11-25 1022/week @ 2024-12-02

4,050 downloads per month
Used in 15 crates (4 directly)

MIT license

560KB
14K SLoC

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

Dependencies

~0.3โ€“0.8MB
~19K SLoC