Skip to content

Commit 9a3f4cb

Browse files
committed
Merge pull request #2066 from mgreter/bugfix/issue_1786
Fix minor issue with handling "\a" in interpolations
2 parents 859aad3 + 2f49f12 commit 9a3f4cb

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/eval.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,16 @@ namespace Sass {
10781078
bool is_null = dynamic_cast<Null*>(item) != 0; // rl != ""
10791079
if (!is_null) *ll << SASS_MEMORY_NEW(ctx.mem, String_Quoted, item->pstate(), rl);
10801080
}
1081-
res += (ll->to_string(ctx.c_options));
1081+
// Check indicates that we probably should not get a list
1082+
// here. Normally single list items are already unwrapped.
1083+
if (l->size() > 1) {
1084+
// string_to_output would fail "#{'_\a' '_\a'}";
1085+
std::string str(ll->to_string(ctx.c_options));
1086+
newline_to_space(str); // replace directly
1087+
res += str; // append to result string
1088+
} else {
1089+
res += (ll->to_string(ctx.c_options));
1090+
}
10821091
ll->is_interpolant(l->is_interpolant());
10831092
}
10841093

src/util.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,14 @@ namespace Sass {
145145
return out;
146146
}
147147

148-
// bell character is replaces with space
148+
// bell characters are replaced with spaces
149+
void newline_to_space(std::string& str)
150+
{
151+
std::replace(str.begin(), str.end(), '\n', ' ');
152+
}
153+
154+
// bell characters are replaced with spaces
155+
// also eats spaces after line-feeds (ltrim)
149156
std::string string_to_output(const std::string& str)
150157
{
151158
std::string out("");

src/util.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace Sass {
2626
std::string evacuate_escapes(const std::string& str);
2727
std::string string_to_output(const std::string& str);
2828
std::string comment_to_string(const std::string& text);
29+
void newline_to_space(std::string& str);
2930

3031
std::string quote(const std::string&, char q = 0);
3132
std::string unquote(const std::string&, char* q = 0, bool keep_utf8_sequences = false);

0 commit comments

Comments
 (0)