Repository navigation
Remove backslash line continuations from the CSS output - #114
Merged
Merged
Conversation
A backslash before a new line continues the line in SugarSS, but the parser kept it in selectors, at-rule params and values. CSS has no such escape, so browsers dropped those rules and declarations. Keep the backslash only in the SugarSS raw, so stringify still gives the input.
Member
|
Thanks. Released in 5.0.2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The README lists "Backslash before new line" among the 3 ways to continue a line for any type of node. The parser keeps the backslash in selectors, at-rule params and declaration values, so the CSS output still has it:
A backslash before a new line is not a valid escape in CSS, and browsers reject it. In Chrome 153 the media query above becomes
not all, an@supportsrule written the same way is dropped, and so is amarginvalue continued with a backslash. With only the backslash removed, all three apply.Now the parser removes the backslash from the value and from
raws[prop].raw, and keeps it inraws[prop].sss, like it does for inline comments, sostringify()still returns the original SugarSS. The newbackslashcase fails onmain; it covers at-rule params, a selector and a declaration value. All 66 tests pass.Related to #91: with this, a multi-line
@apply px-10 \works with Tailwind CSS 4.3.3, while with sugarss 5.0.1 Tailwind reads the backslash as a class name. When the classes start on the next line (@apply \),paramsstill starts with a new line, which Tailwind reads as an empty class. Fixing that needs the new line inraws.afterNameand a SugarSS-only raw to keep the round trip, so I left it out; I can add it if you want.I made
backslash.jsonwithJSON.stringify(jsonify(root), null, 2), becausetest/update-cases.jsnow writes[object Object]:jsonify()from postcss-parser-tests 8.9.0 returns an object.