Skip to content

Commit 249d9f2

Browse files
committed
Fixup sass parser (loud comments missing)
1 parent d14bfae commit 249d9f2

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

src/expand.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,30 @@ namespace Sass {
643643

644644
Statement* Expand::operator()(LoudComment* c)
645645
{
646-
return c;
646+
if (ctx.output_style() == COMPRESSED) {
647+
// comments should not be evaluated in compact
648+
// https://github.com/sass/libsass/issues/2359
649+
if (!true) return NULL;
650+
}
651+
eval.is_in_comment = true;
652+
CommentObj rv;
653+
if (Interpolation * itpl = Cast<Interpolation>(c->text())) {
654+
std::string text = performInterpolation(itpl);
655+
if (ctx.output_style() == COMPRESSED) {
656+
if (text[2] != '!') return nullptr;
657+
}
658+
rv = SASS_MEMORY_NEW(Comment, c->pstate(), SASS_MEMORY_NEW(StringLiteral, "[pstate]", text), true);
659+
}
660+
else {
661+
String* str = Cast<String>(c->text()->perform(&eval));
662+
if (ctx.output_style() == COMPRESSED) {
663+
if (str[2] != '!') return nullptr;
664+
}
665+
rv = SASS_MEMORY_NEW(Comment, c->pstate(), str, true);
666+
}
667+
eval.is_in_comment = false;
668+
// TODO: eval the text, once we're parsing/storing it as a String_Schema
669+
return rv.detach();
647670
}
648671

649672
Statement* Expand::operator()(SilentComment* c)

src/parser_sass.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace Sass {
7171
return StylesheetParser::importArgument();
7272
}
7373

74-
Position start(scanner.offset);
74+
Position start(scanner);
7575
while (scanner.peekChar(next) &&
7676
next != $comma &&
7777
next != $semicolon &&
@@ -80,14 +80,8 @@ namespace Sass {
8080
next = scanner.peekChar();
8181
}
8282

83-
// std::cerr << "got an import\n";
84-
85-
return nullptr;
86-
87-
// return SASS_MEMORY_NEW(DynamicImport,
88-
//
89-
// (parseImportUrl(scanner.substring(start.position)),
90-
// scanner.spanFrom(start));
83+
std::string url = scanner.substring(start);
84+
return SASS_MEMORY_NEW(DynamicImport, "[pstate]", url);
9185

9286
}
9387

@@ -438,7 +432,9 @@ namespace Sass {
438432

439433
if (_nextIndentation > 0) {
440434
if (_spaces == Sass_Indent_Type::AUTO) {
441-
_spaces = Sass_Indent_Type::SPACES;
435+
_spaces = containsSpace ?
436+
Sass_Indent_Type::SPACES :
437+
Sass_Indent_Type::TABS;
442438
}
443439
}
444440
_nextIndentationEnd = scanner.state();

0 commit comments

Comments
 (0)