design.md icon indicating copy to clipboard operation
design.md copied to clipboard

fix(export): escape line terminators in Tailwind v4 CSS string values

Open rmyndharis opened this issue 5 months ago • 0 comments

Summary

The Tailwind v4 exporter wraps font-family values with cssStringLiteral, which escaped only \ and ". A value containing a raw newline / carriage return / form feed — valid via a YAML double-quoted or block scalar in a DESIGN.md — was emitted verbatim inside the @theme CSS string literal. Raw line terminators are illegal inside a CSS string and can break the value out of the quoted token, producing malformed CSS.

This complements the existing token-name validation (which already rejects non-identifier names): names are validated, and string values are now fully escaped.

Fix

Escape \n, \r, and \f as CSS hex escapes (e.g. \a ) in cssStringLiteral, alongside the existing \/" escaping.

Testing

  • bun test: 283 pass, 1 skip, 0 fail (added a test: a font-family containing a newline emits "Evil\a Family" with no raw newline)
  • bun run lint (tsc --noEmit): clean
  • Existing quote/backslash escaping test unchanged and passing

rmyndharis avatar Jun 25 '26 15:06 rmyndharis