fix(printer-postcss): ignore escape \ and escaped / in Less (#5597)
Avoid messing up Less files containing \\/ (escaped /). Ignore escape \ and escaped / in Less.master
parent
cbf06bf388
commit
6a45924379
|
@ -511,6 +511,27 @@ function genericPrint(path, options, print) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore escape `\`
|
||||||
|
if (
|
||||||
|
iNode.value &&
|
||||||
|
iNode.value.indexOf("\\") !== -1 &&
|
||||||
|
iNextNode &&
|
||||||
|
iNextNode.type !== "value-comment"
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore escaped `/`
|
||||||
|
if (
|
||||||
|
iPrevNode &&
|
||||||
|
iPrevNode.value &&
|
||||||
|
iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 &&
|
||||||
|
iNode.type === "value-operator" &&
|
||||||
|
iNode.value === "/"
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore `\` (i.e. `$variable: \@small;`)
|
// Ignore `\` (i.e. `$variable: \@small;`)
|
||||||
if (iNode.value === "\\") {
|
if (iNode.value === "\\") {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -54,6 +54,11 @@ printWidth: 80
|
||||||
content: "\\21D3";
|
content: "\\21D3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ignore escape "\\" in CSS classes */
|
||||||
|
.bar\\/baz {
|
||||||
|
animation-name: \\@mymove;
|
||||||
|
content: "\\21D3";
|
||||||
|
}
|
||||||
|
|
||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
#♥ {
|
#♥ {
|
||||||
|
@ -145,5 +150,11 @@ printWidth: 80
|
||||||
content: "\\21D3";
|
content: "\\21D3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ignore escape "\\" in CSS classes */
|
||||||
|
.bar\\/baz {
|
||||||
|
animation-name: \\@mymove;
|
||||||
|
content: "\\21D3";
|
||||||
|
}
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -46,3 +46,8 @@
|
||||||
content: "\21D3";
|
content: "\21D3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ignore escape "\" in CSS classes */
|
||||||
|
.bar\/baz {
|
||||||
|
animation-name: \@mymove;
|
||||||
|
content: "\21D3";
|
||||||
|
}
|
||||||
|
|
|
@ -1668,6 +1668,15 @@ li + li {
|
||||||
@import // Comment
|
@import // Comment
|
||||||
"@{themes}/tidal-wave.less";
|
"@{themes}/tidal-wave.less";
|
||||||
|
|
||||||
|
// Mixin with escaped /
|
||||||
|
.margin-bottom-1\\/3() {
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
.margin-bottom-1\\/3;
|
||||||
|
}
|
||||||
|
|
||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
@nice-blue: #5b83ad;
|
@nice-blue: #5b83ad;
|
||||||
@light-blue: @nice-blue + #111;
|
@light-blue: @nice-blue + #111;
|
||||||
|
@ -3263,5 +3272,14 @@ li + li {
|
||||||
@import // Comment
|
@import // Comment
|
||||||
"@{themes}/tidal-wave.less";
|
"@{themes}/tidal-wave.less";
|
||||||
|
|
||||||
|
// Mixin with escaped /
|
||||||
|
.margin-bottom-1\\/3() {
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
.margin-bottom-1\\/3;
|
||||||
|
}
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1659,3 +1659,12 @@ li + li {
|
||||||
// Usage
|
// Usage
|
||||||
@import // Comment
|
@import // Comment
|
||||||
"@{themes}/tidal-wave.less";
|
"@{themes}/tidal-wave.less";
|
||||||
|
|
||||||
|
// Mixin with escaped /
|
||||||
|
.margin-bottom-1\/3() {
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
.margin-bottom-1\/3;
|
||||||
|
}
|
||||||
|
|
|
@ -1061,6 +1061,15 @@ $my-map: (
|
||||||
grid-template-columns: 1 2fr (3 + 4);
|
grid-template-columns: 1 2fr (3 + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore escape "\\" in SCSS mixins
|
||||||
|
@mixin margin-bottom-1\\/3 {
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
@include margin-bottom-1\\/3;
|
||||||
|
}
|
||||||
|
|
||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
@media #{$g-breakpoint-tiny} {
|
@media #{$g-breakpoint-tiny} {
|
||||||
}
|
}
|
||||||
|
@ -2015,5 +2024,14 @@ $my-map: (
|
||||||
grid-template-columns: 1 2fr (3 + 4);
|
grid-template-columns: 1 2fr (3 + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore escape "\\" in SCSS mixins
|
||||||
|
@mixin margin-bottom-1\\/3 {
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
@include margin-bottom-1\\/3;
|
||||||
|
}
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1038,3 +1038,12 @@ $my-map: (
|
||||||
.something {
|
.something {
|
||||||
grid-template-columns: 1 2fr (3 + 4);
|
grid-template-columns: 1 2fr (3 + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore escape "\" in SCSS mixins
|
||||||
|
@mixin margin-bottom-1\/3 {
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
@include margin-bottom-1\/3;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue