Interpret newlines as line breaks when converting Markdown to HTML (#74)

This commit is contained in:
Ulyssa 2023-04-06 16:10:48 -07:00
parent 953be6a195
commit ad3b40d538
No known key found for this signature in database
GPG key ID: 1B3965A3D18B9B64
6 changed files with 442 additions and 42 deletions

View file

@ -1027,9 +1027,8 @@ pub mod tests {
Span::raw(""),
Span::raw(" "),
Span::raw(""),
Span::styled(" ", bold),
Span::styled("3", bold),
Span::styled(" ", bold),
Span::styled(" ", bold),
Span::raw("")
]);
@ -1157,4 +1156,21 @@ pub mod tests {
assert_eq!(text.lines[1], Spans(vec![Span::raw("World"), Span::raw(" "),]));
assert_eq!(text.lines[2], Spans(vec![Span::raw("Goodbye")]),);
}
#[test]
fn test_embedded_newline() {
let s = "<p>Hello\nWorld</p>";
let tree = parse_matrix_html(s);
let text = tree.to_text(15, Style::default(), true);
assert_eq!(text.lines.len(), 1);
assert_eq!(
text.lines[0],
Spans(vec![
Span::raw("Hello"),
Span::raw(" "),
Span::raw("World"),
Span::raw(" ")
])
);
}
}