Skip to content

Commit

Permalink
Remove declarations with empty strings from output
Browse files Browse the repository at this point in the history
Fixes sass#1106
  • Loading branch information
mgreter committed Apr 15, 2015
1 parent 8905202 commit 252c622
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ namespace Sass {
} else {
hasDeclarations = true;
}
} else if (Declaration* d = dynamic_cast<Declaration*>(stm)) {
return isPrintable(d, style);
} else {
hasDeclarations = true;
}
Expand All @@ -487,6 +489,28 @@ namespace Sass {
return false;
}

bool isPrintable(String_Constant* s, Output_Style style)
{
return ! s->value().empty();
}

bool isPrintable(String_Quoted* s, Output_Style style)
{
return true;
}

bool isPrintable(Declaration* d, Output_Style style)
{
Expression* val = d->value();
if (String_Quoted* sq = dynamic_cast<String_Quoted*>(val)) return isPrintable(sq, style);
if (String_Constant* sc = dynamic_cast<String_Constant*>(val)) return isPrintable(sc, style);
return true;
}

bool isPrintable(Expression* e, Output_Style style) {
return isPrintable(e, style);
}

bool isPrintable(Feature_Block* f, Output_Style style) {
if (f == NULL) {
return false;
Expand Down
4 changes: 4 additions & 0 deletions util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ namespace Sass {
bool isPrintable(Feature_Block* r, Output_Style style = NESTED);
bool isPrintable(Media_Block* r, Output_Style style = NESTED);
bool isPrintable(Block* b, Output_Style style = NESTED);
bool isPrintable(String_Constant* s, Output_Style style = NESTED);
bool isPrintable(String_Quoted* s, Output_Style style = NESTED);
bool isPrintable(Declaration* d, Output_Style style = NESTED);
bool isPrintable(Expression* e, Output_Style style = NESTED);
bool isAscii(const char chr);

}
Expand Down

0 comments on commit 252c622

Please sign in to comment.