cssesc
Escape a string for use as a CSS string or identifier (selector).
A faithful Rust port of the widely-used cssesc npm
package by Mathias Bynens.
- Zero dependencies,
#![no_std] - String or identifier mode, single/double quotes, wrapping, escape-everything
- Differential-tested against the reference
cssescimplementation (60k cases, all options)
Install
[]
= "0.1"
Usage
use ;
assert_eq!;
assert_eq!;
assert_eq!;
// Identifier (selector) mode escapes more, and fixes leading digits/dashes:
let id = new.is_identifier;
assert_eq!;
assert_eq!;
// Choose quotes and wrap:
assert_eq!;
Contributors ✨
This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.
Thanks goes to these wonderful people:
License
Licensed under either of MIT or Apache-2.0 at your option.