muskitty-css-values
A typed CSS value parser implementing CSS Values Level 4
and CSS Variables Level 1, built on
muskitty-css-parser.
Part of the MusKitty browser engine project.
Status
| Component | Spec | Tests |
|---|---|---|
| Numeric types (Length/Angle/Time/...) | CSS Values §4.4-§4.7, §5, §6 | 33 |
| Textual types (Keyword/Ident/String/Url) | CSS Values §3 | 25 |
| Math expressions (calc/min/max/clamp) | CSS Values §9 | 36 |
| var() references | CSS Variables §2-§3 | 12 |
| Grammar hooks + serialization | CSS Values §5.4.1, §8.1, §9.7 | 33 |
| Total | 148 |
- Zero
unsafecode - Zero C/C++ dependencies
- Runtime dependency:
muskitty-css(facade over tokenizer + parser) - Rust stable toolchain only
- MSRV 1.82
Installation
[]
= "0.1.0"
Quick Start
use ;
let val = parse_value.unwrap;
// CssValue::Math(MathExpression::Sum(...))
Architecture
muskitty-css-values/
src/
lib.rs Public API + re-exports
numeric.rs Length/Percentage/Number/Integer/Angle/Time/
Frequency/Resolution/Ratio (§4.4-§4.7, §5, §6)
textual.rs Keyword/CustomIdent/DashedIdent/CssString/Url (§3)
math.rs MathExpression AST + calc/min/max/clamp parser (§9)
var.rs VarReference parsing (CSS Variables §3)
grammar.rs ValuesGrammar impl Grammar trait (§5.4.1)
serialize.rs ToCss trait + serialization (§8.1, §9.7)
tests/
5 test files, 148 tests total
Design Principles
- Parse, don't compute — This crate builds typed ASTs. Numeric resolution, var() substitution, and calc() evaluation happen in the cascade layer.
- CSSWG is ground truth — Implementation follows the spec exactly.
- Zero unsafe — Pure safe Rust.
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Copyright 2026 MusCat / MusKitty Bit-Torch Community