Commit e6cdd02f22

e6cdd02f2243066e2a1add1b285fe3f84cf6d64b

parent: 0bc4ff07b0

Unregistered key

Ulyssa <git@ulyssa.dev> · 2023-03-21 00:53 UTC

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

Layout: unified · split

src/message/html.rs +12 −1
@@ -619,7 +619,7 @@ pub fn parse_matrix_html(s: &str) -> StyleTree {
619619 let dom = parse_fragment(
620620 RcDom::default(),
621621 ParseOpts::default(),
622 QualName::new(None, ns!(), local_name!("div")),
622 QualName::new(None, ns!(html), local_name!("body")),
623623 vec![],
624624 )
625625 .one(StrTendril::from(s));
@@ -1147,4 +1147,15 @@ pub mod tests {
11471147 ])
11481148 );
11491149 }
1150
1151 #[test]
1152 fn test_self_closing() {
1153 let s = "Hello<br>World<br>Goodbye";
1154 let tree = parse_matrix_html(s);
1155 let text = tree.to_text(7, Style::default(), true);
1156 assert_eq!(text.lines.len(), 3);
1157 assert_eq!(text.lines[0], Spans(vec![Span::raw("Hello"), Span::raw(" "),]));
1158 assert_eq!(text.lines[1], Spans(vec![Span::raw("World"), Span::raw(" "),]));
1159 assert_eq!(text.lines[2], Spans(vec![Span::raw("Goodbye")]),);
1160 }
11501161}