# tsv_css
CSS formatting and parsing to the wire JSON of Svelte's `parseCss` — part of
[tsv](https://github.com/fuzdev/tsv) ([tsv.fuz.dev](https://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.
```rust
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](https://docs.rs/tsv_css).
Minimum supported Rust version: 1.94; raising it ships in a minor release. Release notes:
[CHANGELOG.md](https://github.com/fuzdev/tsv/blob/main/CHANGELOG.md).
License: [0BSD](https://github.com/fuzdev/tsv/blob/main/LICENSE)