Commit 6030f08c by Aaron Leung

Expanded-style output is looking good.

parent e476b60c
...@@ -68,13 +68,15 @@ namespace Sass { ...@@ -68,13 +68,15 @@ namespace Sass {
} }
} }
void Node::emit_expanded_css(stringstream& buf, string prefix) { void Node::emit_expanded_css(stringstream& buf, const string& prefix) {
switch (type) { switch (type) {
case value: case value:
case selector: case selector:
if (!prefix.empty()) buf << " ";
buf << string(token); buf << string(token);
break; break;
case comment: case comment:
if (!prefix.empty()) buf << " ";
buf << string(token) << endl; buf << string(token) << endl;
break; break;
case property: case property:
...@@ -99,9 +101,10 @@ namespace Sass { ...@@ -99,9 +101,10 @@ namespace Sass {
opt_children[i].emit_expanded_css(buf, prefix); opt_children[i].emit_expanded_css(buf, prefix);
break; break;
case ruleset: case ruleset:
buf << prefix << " "; buf << prefix;
children[0].emit_expanded_css(buf, prefix); children[0].emit_expanded_css(buf, prefix);
children[1].emit_expanded_css(buf, prefix + string(children[0].token)); string newprefix(prefix.empty() ? prefix : prefix + " ");
children[1].emit_expanded_css(buf, newprefix + string(children[0].token));
break; break;
} }
} }
......
...@@ -33,6 +33,6 @@ namespace Sass { ...@@ -33,6 +33,6 @@ namespace Sass {
void push_child(const Node& node); void push_child(const Node& node);
void push_opt_child(const Node& node); void push_opt_child(const Node& node);
void dump(unsigned int depth = 0); void dump(unsigned int depth = 0);
void emit_expanded_css(std::stringstream& buf, string prefix); void emit_expanded_css(std::stringstream& buf, const string& prefix);
}; };
} }
\ No newline at end of file
/* top level comment -- should preserved */
div { div {
/* a comment that should be preserved */ /* another comment that should be preserved */
color: red; color: red;
background: blue; background: blue;
span { span {
...@@ -8,8 +9,13 @@ div { ...@@ -8,8 +9,13 @@ div {
text-decoration: none; text-decoration: none;
color: green; color: green;
} }
/* second comment that should be preserved */ /* yet another comment that should be preserved */
display: inline-block; display: inline-block;
} }
p {
padding: 10px 8%;
}
margin: 10px 5px; margin: 10px 5px;
} }
/* last comment, top level again --
compare the indentation! */
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment