muskitty-css-values 0.1.1

CSS Values Level 4 typed value parsing (length/angle/time/calc/var)
Documentation
  • Coverage
  • 38.42%
    73 out of 190 items documented8 out of 82 items with examples
  • Size
  • Source code size: 113.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.4 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • muskitty-dev/muskitty-css-values
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • muskitty-dev

muskitty-css-values

English | 简体中文

crates.io Documentation License

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 unsafe code
  • Zero C/C++ dependencies
  • Runtime dependency: muskitty-css (facade over tokenizer + parser)
  • Rust stable toolchain only
  • MSRV 1.82

Installation

[dependencies]
muskitty-css-values = "0.1.0"

Quick Start

use muskitty_css_values::{parse_value, CssValue};

let val = parse_value("calc(100% - 2em)").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

  1. Parse, don't compute — This crate builds typed ASTs. Numeric resolution, var() substitution, and calc() evaluation happen in the cascade layer.
  2. CSSWG is ground truth — Implementation follows the spec exactly.
  3. 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