Skip to content

Commit 82849f1

Browse files
authored
fix: handle escaped newlines in heredocs (#41)
1 parent 1ba1301 commit 82849f1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/parser/tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ fn unescape_strings() {
423423
object_attr = {
424424
"key\nwith\nnewlines" = true
425425
}
426+
427+
heredoc = <<-EOS
428+
some string with \
429+
escaped newline
430+
EOS
426431
}
427432
"#;
428433

@@ -437,6 +442,7 @@ fn unescape_strings() {
437442
"object_attr",
438443
Expression::from_iter([("key\nwith\nnewlines", true)]),
439444
))
445+
.add_attribute(("heredoc", "some string with escaped newline\n"))
440446
.build(),
441447
)
442448
.build();

src/parser/unescape.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub fn unescape(s: &str) -> Result<String> {
2020
}
2121

2222
let c = match chars.next() {
23+
Some('\n') => continue,
2324
Some('b') => '\u{0008}',
2425
Some('f') => '\u{000C}',
2526
Some('n') => '\n',

0 commit comments

Comments
 (0)