Skip to content

Commit c68b0a0

Browse files
committed
Merge pull request #1109 from mgreter/bugfix/issue_1106
Remove declarations with empty strings from output
2 parents 8905202 + 252c622 commit c68b0a0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

util.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ namespace Sass {
475475
} else {
476476
hasDeclarations = true;
477477
}
478+
} else if (Declaration* d = dynamic_cast<Declaration*>(stm)) {
479+
return isPrintable(d, style);
478480
} else {
479481
hasDeclarations = true;
480482
}
@@ -487,6 +489,28 @@ namespace Sass {
487489
return false;
488490
}
489491

492+
bool isPrintable(String_Constant* s, Output_Style style)
493+
{
494+
return ! s->value().empty();
495+
}
496+
497+
bool isPrintable(String_Quoted* s, Output_Style style)
498+
{
499+
return true;
500+
}
501+
502+
bool isPrintable(Declaration* d, Output_Style style)
503+
{
504+
Expression* val = d->value();
505+
if (String_Quoted* sq = dynamic_cast<String_Quoted*>(val)) return isPrintable(sq, style);
506+
if (String_Constant* sc = dynamic_cast<String_Constant*>(val)) return isPrintable(sc, style);
507+
return true;
508+
}
509+
510+
bool isPrintable(Expression* e, Output_Style style) {
511+
return isPrintable(e, style);
512+
}
513+
490514
bool isPrintable(Feature_Block* f, Output_Style style) {
491515
if (f == NULL) {
492516
return false;

util.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ namespace Sass {
4141
bool isPrintable(Feature_Block* r, Output_Style style = NESTED);
4242
bool isPrintable(Media_Block* r, Output_Style style = NESTED);
4343
bool isPrintable(Block* b, Output_Style style = NESTED);
44+
bool isPrintable(String_Constant* s, Output_Style style = NESTED);
45+
bool isPrintable(String_Quoted* s, Output_Style style = NESTED);
46+
bool isPrintable(Declaration* d, Output_Style style = NESTED);
47+
bool isPrintable(Expression* e, Output_Style style = NESTED);
4448
bool isAscii(const char chr);
4549

4650
}

0 commit comments

Comments
 (0)