tsv_css 0.8.0

CSS formatter and parser compatible with Svelte's parseCss — part of tsv
Documentation
  • Coverage
  • 100%
    8 out of 8 items documented6 out of 8 items with examples
  • Size
  • Source code size: 1.6 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.4 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • fuzdev/tsv
    28 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ryanatkn

tsv_css

CSS formatting and parsing to the wire JSON of Svelte's parseCss — part of tsv (tsv.fuz.dev).

  • format formats one source; a Formatter formats many on one thread, keeping its arenas warm between calls.
  • parse_to_json parses to the wire JSON AST (the default json feature).
  • run_with_stack runs a call on a thread reserving STACK_SIZE, for a thread whose stack may be too small for the deepest input tsv accepts.
use tsv_css::{Formatter, format};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    assert_eq!(format("a{color:red}")?, "a {\n\tcolor: red;\n}\n");
    let mut formatter = Formatter::new(); // warm arenas, for many sources on one thread
    assert_eq!(formatter.format("b{margin:0}")?, "b {\n\tmargin: 0;\n}\n");
    Ok(())
}

This release exposes no AST: parsing returns the wire JSON — the AST as JSON in the canonical parser's shape (Svelte's parseCss's), its start / end UTF-16 offsets, span-only by default (no loc; the locations feature adds it), unlike an error's span(), a UTF-8 byte range.

The formatter is non-configurable by design: Prettier's style with printWidth 100, tabs and single quotes. Formatting output is not frozen: it changes between releases as formatting bugs are fixed.

API docs: docs.rs/tsv_css.

Minimum supported Rust version: 1.94; raising it ships in a minor release. Release notes: CHANGELOG.md.

License: 0BSD