Skip to content

Commit f8f3f4a

Browse files
authored
Merge pull request leafo#703 from Cerdic/Issue/leafo/586
backslash-newline in strings
2 parents 8730f9b + fc89a5f commit f8f3f4a

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
lines changed

src/Parser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,11 @@ protected function string(&$out)
19681968
$content[] = $m[2] . "'";
19691969
} elseif ($this->literal("\\", 1, false)) {
19701970
$content[] = $m[2] . "\\";
1971+
} elseif ($this->literal("\r\n", 2, false)
1972+
|| $this->matchChar("\r", false)
1973+
|| $this->matchChar("\n", false)
1974+
|| $this->matchChar("\f", false)) {
1975+
// this is a continuation escaping, to be ignored
19711976
} else {
19721977
$content[] = $m[2];
19731978
}

tests/inputs/interpolation.scss

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,15 @@ div {
139139
}
140140
.element {
141141
@include set-border(#{2px}); // compiles to "2px solid #000"
142-
}
142+
}
143+
144+
$foo: "\
145+
div > p, \
146+
div > h1 \
147+
";
148+
149+
#{$foo} {
150+
& > strong {
151+
color: red;
152+
}
153+
}

tests/outputs/interpolation.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@ a.badge {
7777

7878
.element {
7979
border: 2px solid #000; }
80+
81+
div > p > strong, div > h1 > strong {
82+
color: red; }

tests/outputs/values.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
background-image: url(//host/image.png);
99
dads: url(http://leafo.net);
1010
padding: 10px 10px 10px 10px, 3px 3px 3px;
11-
textblock: "This is a \
12-
multiline block \
13-
#not { color: #eee;}";
11+
textblock: "This is a multiline block #not { color: #eee;}";
1412
margin: 4, 3, 1;
15-
content: "This is a \
16-
multiline string.";
13+
content: "This is a multiline string.";
1714
border-radius: -1px -1px -1px black;
1815
grid-template-columns: [avatar] 2fr [body] 6fr; }
1916

tests/outputs_numbered/interpolation.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,8 @@ a.badge {
9696
/* line 140, inputs/interpolation.scss */
9797
.element {
9898
border: 2px solid #000; }
99+
/* line 149, inputs/interpolation.scss */
100+
/* line 150, inputs/interpolation.scss */
101+
102+
div > p > strong, div > h1 > strong {
103+
color: red; }

tests/outputs_numbered/values.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
background-image: url(//host/image.png);
1010
dads: url(http://leafo.net);
1111
padding: 10px 10px 10px 10px, 3px 3px 3px;
12-
textblock: "This is a \
13-
multiline block \
14-
#not { color: #eee;}";
12+
textblock: "This is a multiline block #not { color: #eee;}";
1513
margin: 4, 3, 1;
16-
content: "This is a \
17-
multiline string.";
14+
content: "This is a multiline string.";
1815
border-radius: -1px -1px -1px black;
1916
grid-template-columns: [avatar] 2fr [body] 6fr; }
2017
/* line 23, inputs/values.scss */

0 commit comments

Comments
 (0)