File tree 3 files changed +15
-2
lines changed
3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -112,12 +112,15 @@ public function parseCharacter($bIsForIdentifier) {
112
112
return null ;
113
113
}
114
114
115
- public function consumeWhiteSpace () {
115
+ public function consumeWhiteSpace ($ consumeComments = true ) {
116
116
$ comments = array ();
117
117
do {
118
118
while (preg_match ('/ \\s/isSu ' , $ this ->peek ()) === 1 ) {
119
119
$ this ->consume (1 );
120
120
}
121
+ if (!$ consumeComments ) {
122
+ return ;
123
+ }
121
124
if ($ this ->oParserSettings ->bLenientParsing ) {
122
125
try {
123
126
$ oComment = $ this ->consumeComment ();
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public static function parse(ParserState $oParserState) {
56
56
while ($ oParserState ->comes ('; ' )) {
57
57
$ oParserState ->consume ('; ' );
58
58
}
59
- $ oParserState ->consumeWhiteSpace ();
59
+ $ oParserState ->consumeWhiteSpace (false );
60
60
61
61
return $ oRule ;
62
62
}
Original file line number Diff line number Diff line change @@ -733,6 +733,16 @@ function testFlatCommentExtracting() {
733
733
$ this ->assertEquals ("Find Me! " , $ comments [0 ]->getComment ());
734
734
}
735
735
736
+ function testInnerCommentExtracting () {
737
+ $ parser = new Parser ('div {left:10px;/*Find Me!*/text-align:left;} ' );
738
+ $ doc = $ parser ->parse ();
739
+ $ contents = $ doc ->getContents ();
740
+ $ divRules = $ contents [0 ]->getRules ();
741
+ $ comments = $ divRules [1 ]->getComments ();
742
+ $ this ->assertCount (1 , $ comments );
743
+ $ this ->assertEquals ("Find Me! " , $ comments [0 ]->getComment ());
744
+ }
745
+
736
746
function testTopLevelCommentExtracting () {
737
747
$ parser = new Parser ('/*Find Me!*/div {left:10px; text-align:left;} ' );
738
748
$ doc = $ parser ->parse ();
You can’t perform that action at this time.
0 commit comments