Skip to content

Commit

Permalink
fix(newlines_to_br): should preserve newlines
Browse files Browse the repository at this point in the history
fixes #259
  • Loading branch information
Goncalerta committed Dec 1, 2018
1 parent 9235289 commit 01904ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/filters/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn newline_to_br(input: &Value, args: &[Value]) -> FilterResult {

// TODO handle windows line endings
let input = input.to_str();
Ok(Value::scalar(input.replace("\n", "<br />")))
Ok(Value::scalar(input.replace("\n", "<br />\n")))
}

#[cfg(test)]
Expand Down Expand Up @@ -200,7 +200,7 @@ mod tests {
fn unit_newline_to_br() {
let input = &tos!("a\nb");
let args = &[];
let desired_result = tos!("a<br />b");
let desired_result = tos!("a<br />\nb");
assert_eq!(unit!(newline_to_br, input, args), desired_result);
}

Expand All @@ -209,7 +209,7 @@ mod tests {
// First example from https://shopify.github.io/liquid/filters/newline_to_br/
let input = &tos!("\nHello\nWorld\n");
let args = &[];
let desired_result = tos!("<br />Hello<br />World<br />");
let desired_result = tos!("<br />\nHello<br />\nWorld<br />\n");
assert_eq!(unit!(newline_to_br, input, args), desired_result);
}

Expand Down
1 change: 0 additions & 1 deletion tests/conformance_ruby/standard_filter_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,6 @@ fn test_strip_newlines() {
}

#[test]
#[ignore]
fn test_newlines_to_br() {
assert_template_result!(
"a<br />\nb<br />\nc",
Expand Down

0 comments on commit 01904ed

Please sign in to comment.