7 releases (breaking)

new 0.6.0 Sep 27, 2023
0.5.1 Sep 18, 2023
0.4.0 Sep 7, 2023
0.3.0 Jul 16, 2023
0.1.0 Sep 25, 2022

#41 in Multimedia

Download history 8/week @ 2023-06-03 4/week @ 2023-06-10 18/week @ 2023-06-17 10/week @ 2023-06-24 18/week @ 2023-07-01 11/week @ 2023-07-08 42/week @ 2023-07-15 14/week @ 2023-07-22 13/week @ 2023-07-29 24/week @ 2023-08-05 13/week @ 2023-08-12 7/week @ 2023-08-19 7/week @ 2023-08-26 22/week @ 2023-09-02 35/week @ 2023-09-09 34/week @ 2023-09-16

99 downloads per month
Used in dprint-plugin-css

MIT license

545KB
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.

๐Ÿ—๏ธ Current Status

  • CSS: Almost completed.
  • SCSS/Sass: Almost completed.
  • Less: Almost completed.

โŒ› 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 +nightly criterion.

โœจ Credit

Tests come from:

๐Ÿ“œ License

MIT License

Copyright (c) 2022-present Pig Fang

Dependencies

~1.1โ€“1.6MB
~38K SLoC