From e6cdd02f2243066e2a1add1b285fe3f84cf6d64b Mon Sep 17 00:00:00 2001 From: Ulyssa Date: Mon, 20 Mar 2023 17:53:55 -0700 Subject: [PATCH] HTML self-closing tags are getting parsed incorrectly (#63) --- src/message/html.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/message/html.rs b/src/message/html.rs index c79d7d5..c8b1de2 100644 --- a/src/message/html.rs +++ b/src/message/html.rs @@ -619,7 +619,7 @@ pub fn parse_matrix_html(s: &str) -> StyleTree { let dom = parse_fragment( RcDom::default(), ParseOpts::default(), - QualName::new(None, ns!(), local_name!("div")), + QualName::new(None, ns!(html), local_name!("body")), vec![], ) .one(StrTendril::from(s)); @@ -1147,4 +1147,15 @@ pub mod tests { ]) ); } + + #[test] + fn test_self_closing() { + let s = "Hello
World
Goodbye"; + let tree = parse_matrix_html(s); + let text = tree.to_text(7, Style::default(), true); + assert_eq!(text.lines.len(), 3); + assert_eq!(text.lines[0], Spans(vec![Span::raw("Hello"), Span::raw(" "),])); + assert_eq!(text.lines[1], Spans(vec![Span::raw("World"), Span::raw(" "),])); + assert_eq!(text.lines[2], Spans(vec![Span::raw("Goodbye")]),); + } }