2 unstable releases

0.20.0 Nov 28, 2023
0.19.0 Dec 10, 2022

#102 in Text editors

Download history 873/week @ 2023-12-11 625/week @ 2023-12-18 526/week @ 2023-12-25 572/week @ 2024-01-01 667/week @ 2024-01-08 879/week @ 2024-01-15 1589/week @ 2024-01-22 1498/week @ 2024-01-29 1125/week @ 2024-02-05 970/week @ 2024-02-12 1185/week @ 2024-02-19 792/week @ 2024-02-26 717/week @ 2024-03-04 743/week @ 2024-03-11 735/week @ 2024-03-18 844/week @ 2024-03-25

3,128 downloads per month
Used in 12 crates (9 directly)

MIT license

410KB
14K SLoC

C 14K SLoC JavaScript 319 SLoC // 0.1% comments Scheme 52 SLoC Rust 35 SLoC

tree-sitter-css

This crate provides a CSS grammar for the tree-sitter parsing library. To use this crate, add it to the [dependencies] section of your Cargo.toml file. (Note that you will probably also need to depend on the tree-sitter crate to use the parsed result in any useful way.)

[dependencies]
tree-sitter = "~0.20.10"
tree-sitter-css = "0.20.0"

Typically, you will use the language function to add this grammar to a tree-sitter Parser, and then use the parser to parse some code:

let code = r#"
  .foo {
    color: red;
  }
"#;
let mut parser = Parser::new();
parser.set_language(tree_sitter_css::language()).expect("Error loading CSS grammar");
let parsed = parser.parse(code, None);

If you have any questions, please reach out to us in the tree-sitter discussions page.

Dependencies

~2.7–4MB
~71K SLoC