HTML self-closing tags are getting parsed incorrectly (#63)

This commit is contained in:
Ulyssa 2023-03-20 17:53:55 -07:00
parent 0bc4ff07b0
commit e6cdd02f22
No known key found for this signature in database
GPG key ID: 1B3965A3D18B9B64

View file

@ -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<br>World<br>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")]),);
}
}