Skip to content

Commit

Permalink
beautifier#1976 adding support for the new @forwards syntax in SASS
Browse files Browse the repository at this point in the history
  • Loading branch information
mhnaeem committed Apr 11, 2022
1 parent ed2e08d commit 8894924
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
7 changes: 6 additions & 1 deletion js/src/css/beautifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,12 @@ Beautifier.prototype.beautify = function() {
}
}
} else {
this.preserveSingleSpace(isAfterSpace);
var space_needed = false;
if (this._input.lookBack("with")) {
// look back is not an accurate solution, we need tokens to confirm without whitespaces
space_needed = true;
}
this.preserveSingleSpace(isAfterSpace || space_needed);
this.print_string(this._ch);

// handle scss/sass map
Expand Down
6 changes: 5 additions & 1 deletion python/cssbeautifier/css/beautifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,11 @@ def beautify(self):
parenLevel -= 1
self.outdent()
else:
self.preserveSingleSpace(isAfterSpace)
space_needed = False
if self._input.lookBack("with"):
# look back is not an accurate solution, we need tokens to confirm without whitespaces
space_needed = True
self.preserveSingleSpace(isAfterSpace or space_needed)
self.print_string(self._ch)

# handle scss/sass map
Expand Down
11 changes: 10 additions & 1 deletion test/data/css/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1504,10 +1504,19 @@ exports.test_data = {
]
}]
}, {
name: "Issue #1798 - space after strings in preserved",
name: "Regression tests - with default options",
description: "",
tests: [{
comment: "Issue #1798 - space after strings in preserved",
unchanged: '@use "variables" as *;'
}, {
comment: "Issue #1976 - support the new @forwards syntax",
input: [
'@forwards "a" with (',
' $a: 2',
');'
],
output: '@forwards "a" with ($a: 2);'
}]
}, {
name: "Issue #1817",
Expand Down

0 comments on commit 8894924

Please sign in to comment.