Skip to content

Commit 0797686

Browse files
committed
add trailing newline on read when missing
1 parent a4a3d82 commit 0797686

File tree

1 file changed

+8
-0
lines changed
  • crates/quarto-markdown-pandoc/src/readers

1 file changed

+8
-0
lines changed

crates/quarto-markdown-pandoc/src/readers/qmd.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ pub fn read<T: Write>(
6868
_ => {}
6969
})));
7070

71+
// inefficient, but safe: if no trailing newline, add one
72+
if !input_bytes.ends_with(b"\n") {
73+
let mut input_bytes_with_newline = Vec::with_capacity(input_bytes.len() + 1);
74+
input_bytes_with_newline.extend_from_slice(input_bytes);
75+
input_bytes_with_newline.push(b'\n');
76+
return read(&input_bytes_with_newline, _loose, filename, output_stream);
77+
}
78+
7179
let tree = parser
7280
.parse(&input_bytes, None)
7381
.expect("Failed to parse input");

0 commit comments

Comments
 (0)