3 unstable releases

0.2.1 Jul 20, 2021
0.2.0 Aug 17, 2019
0.1.0 Jan 14, 2017

#1869 in Parser implementations

Download history 39355/week @ 2024-06-17 43478/week @ 2024-06-24 37546/week @ 2024-07-01 40598/week @ 2024-07-08 38692/week @ 2024-07-15 39043/week @ 2024-07-22 36254/week @ 2024-07-29 34778/week @ 2024-08-05 34871/week @ 2024-08-12 39182/week @ 2024-08-19 43642/week @ 2024-08-26 44671/week @ 2024-09-02 42170/week @ 2024-09-09 41363/week @ 2024-09-16 45909/week @ 2024-09-23 43153/week @ 2024-09-30

175,413 downloads per month
Used in 346 crates (6 directly)

MIT/Apache

45KB
1K SLoC

simplecss

Build Status Crates.io Documentation Rust 1.37+

A simple CSS 2.1 parser and selector.

This is not a browser-grade CSS parser. If you need one, use cssparser + selectors.

Since it's very simple we will start with limitations:

Limitations

  • At-rules are not supported. They will be skipped during parsing.
  • Property values are not parsed. In CSS like * { width: 5px } you will get a width property with a 5px value as a string.
  • CDO/CDC comments are not supported.
  • Parser is case sensitive. All keywords must be lowercase.
  • Unicode escape, like \26, is not supported.

Features

  • Selector matching support.
  • The rules are sorted by specificity.
  • !import parsing support.
  • Has a high-level parsers and low-level, zero-allocation tokenizers.
  • No unsafe.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~87KB