lukeed/tidyPublic

feat: format css

A port of bun's port of Prettier's CSS printer and the four parsers it
uses, as tidyrs::css with Css, Scss and Less dialects. Statements are
written straight to the output when every group on a line fits flat,
as bun does. One that doesn't goes through a small builder into the
shared doc IR, which print_at prints in place.

Markup now formats <style> and style="" with it unless the embed hook
answers first, and embeds the CSS document rather than its text.
format_embedded is Prettier's embeddedLanguageFormatting: off, neither
the hook nor the built-in formatters run. All formatters keep a byte
order mark, as Prettier does.

Conformance: CSS 158/160, SCSS 135/136, Less 236/238. The misses are
bun's corrections of custom property values, and the same embedded in
markup matches Prettier fixture for fixture.
LELuke Edwards authored
aa28c41Patch
Parent5d439d7
31 files changed+9509-91
StackedSplit
crates/tidyrs/src/css/media_query.rs+228 −0
crates/tidyrs/src/css/memo.rs+126 −0
crates/tidyrs/src/css/misc.rs+328 −0
crates/tidyrs/src/css/mod.rs+378 −0
crates/tidyrs/src/css/parse.rs+874 −0
crates/tidyrs/src/css/postcss.rs+1554 −0
crates/tidyrs/src/css/printer.rs+1672 −0
crates/tidyrs/src/css/selector_parser.rs+657 −0
crates/tidyrs/src/css/sink.rs+684 −0
crates/tidyrs/src/css/value_groups.rs+1151 −0
crates/tidyrs/src/css/value_parser.rs+1256 −0
crates/tidyrs/src/doc/mod.rs+1 −0
crates/tidyrs/src/doc/print.rs+48 −15
crates/tidyrs/src/handlebars/lexer.rs+3 −32
crates/tidyrs/src/handlebars/mod.rs+31 −8
crates/tidyrs/src/handlebars/parser.rs+1 −1
crates/tidyrs/src/handlebars/printer.rs+30 −5
crates/tidyrs/src/handlebars/tokenizer.rs+1 −1
crates/tidyrs/src/html/embed.rs+46 −6
crates/tidyrs/src/html/mod.rs+22 −3
crates/tidyrs/src/lib.rs+19 −0
crates/tidyrs/src/strings.rs+66 −0
crates/tidyrs/src/syntax.rs+13 −1
crates/tidyrs/src/text.rs+200 −0
crates/tidyrs/tests/css.rs+30 −0
crates/tidyrs/tests/html.rs+2 −2
crates/tidyrs_cli/src/main.rs+37 −5
crates/tidyrs_napi/src/lib.rs+37 −5
notice.md+3 −2
tests/oracle/conformance.ts+9 −4
tests/oracle/tempura.ts+2 −1