Skip to content

Commit 66ff686

Browse files
committed
fixes #77
1 parent 072e9ea commit 66ff686

File tree

5 files changed

+143
-14
lines changed

5 files changed

+143
-14
lines changed

scss.inc.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,10 @@ public function parse($buffer)
27412741
$this->buffer = $buffer;
27422742

27432743
$this->pushBlock(null); // root block
2744+
27442745
$this->whitespace();
2746+
$this->pushBlock(null);
2747+
$this->popBlock();
27452748

27462749
while (false !== $this->parseChunk())
27472750
;
@@ -4328,6 +4331,23 @@ public function adjustAllChildren($block) {
43284331
}
43294332
}
43304333

4334+
protected function blockLines($inner, $block)
4335+
{
4336+
$glue = $this->break . $inner;
4337+
4338+
foreach ($block->lines as $index => $line) {
4339+
if (substr($line, 0, 2) === '/*') {
4340+
$block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line);
4341+
}
4342+
}
4343+
4344+
echo $inner . implode($glue, $block->lines);
4345+
4346+
if (!empty($block->children)) {
4347+
echo $this->break;
4348+
}
4349+
}
4350+
43314351
protected function block($block) {
43324352
if ($block->type == 'root') {
43334353
$this->adjustAllChildren($block);

tests/inputs/parsing_comments.scss

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* comment 1 */
2+
a {
3+
/* comment 2 */
4+
color: red; /* comment 3 */
5+
/* comment 4 */
6+
}
7+
/* comment 5 */
8+
9+
/*! comment 1 */
10+
b {
11+
/*! comment 2 */
12+
color: red; /*! comment 3 */
13+
/*! comment 4 */
14+
}
15+
/*! comment 5 */
16+
17+
/*
18+
* multi-line comment 1
19+
*/
20+
c {
21+
/*
22+
* multi-line comment 2
23+
*/
24+
color: red; /*
25+
* multi-line comment 3
26+
*/
27+
/*
28+
* multi-line comment 4
29+
*/
30+
}
31+
/*
32+
* multi-line comment 5
33+
*/
34+
35+
/*!
36+
* multi-line comment 1
37+
*/
38+
d {
39+
/*!
40+
* multi-line comment 2
41+
*/
42+
color: red; /*!
43+
* multi-line comment 3
44+
*/
45+
/*!
46+
* multi-line comment 4
47+
*/
48+
}
49+
/*!
50+
* multi-line comment 5
51+
*/
52+
53+
// comment 1
54+
e {
55+
// comment 2
56+
color: red; // comment 3
57+
// comment 4
58+
}
59+
// comment 5

tests/outputs/comments.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Here is a block comment
44
**/
55
/*hello*/
6-
/*yeah*/
76
div {
7+
/*yeah*/
88
border: 1px solid red;
99
/* another property */
1010
color: url('http://mage-page.com');

tests/outputs/parsing_comments.css

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* comment 1 */
2+
a {
3+
/* comment 2 */
4+
color: red;
5+
/* comment 3 */
6+
/* comment 4 */ }
7+
/* comment 5 */
8+
/*! comment 1 */
9+
b {
10+
/*! comment 2 */
11+
color: red;
12+
/*! comment 3 */
13+
/*! comment 4 */ }
14+
/*! comment 5 */
15+
/*
16+
* multi-line comment 1
17+
*/
18+
c {
19+
/*
20+
* multi-line comment 2
21+
*/
22+
color: red;
23+
/*
24+
* multi-line comment 3
25+
*/
26+
/*
27+
* multi-line comment 4
28+
*/ }
29+
/*
30+
* multi-line comment 5
31+
*/
32+
/*!
33+
* multi-line comment 1
34+
*/
35+
d {
36+
/*!
37+
* multi-line comment 2
38+
*/
39+
color: red;
40+
/*!
41+
* multi-line comment 3
42+
*/
43+
/*!
44+
* multi-line comment 4
45+
*/ }
46+
/*!
47+
* multi-line comment 5
48+
*/
49+
e {
50+
color: red; }

tests/outputs/scss_css.css

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ sel {
3939

4040
.foo {
4141
/* Foo
42-
Bar
43-
Baz */
42+
Bar
43+
Baz */
4444
a: b; }
4545

4646
.foo {
4747
/* Foo
48-
Bar
49-
Baz */
48+
Bar
49+
Baz */
5050
a: b; }
5151

5252
.foo {
5353
/* Foo
54-
Bar */
54+
Bar */
5555
a: b; }
5656

5757
.foo {
5858
/* Foo
59-
Bar
60-
Baz */
59+
Bar
60+
Baz */
6161
a: b; }
6262

6363
@foo {
@@ -227,7 +227,7 @@ foo {
227227
* Bar */
228228
.foo {
229229
/* Foo
230-
* Bar */ }
230+
* Bar */ }
231231

232232
[foo] {
233233
a: b; }
@@ -400,9 +400,9 @@ foo {
400400

401401
.foo {
402402
/* Foo
403-
* Bar */
403+
* Bar */
404404
/* Baz
405-
* Bang */ }
405+
* Bang */ }
406406

407407
.foo {
408408
/* Foo Bar */
@@ -550,7 +550,7 @@ foo {
550550

551551
.foo {
552552
/* Foo
553-
* Bar */
553+
* Bar */
554554
a: b; }
555555
/* Foo */
556556
.foo {
@@ -599,8 +599,8 @@ E, F G, H {
599599

600600
body {
601601
/*
602-
//comment here
603-
*/ }
602+
//comment here
603+
*/ }
604604

605605
E > F {
606606
a: b; }

0 commit comments

Comments
 (0)