From f528a45568af1a476026191d51143f58091ca377 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 4 Sep 2019 18:14:39 +0200 Subject: [PATCH] xhtml: Automatically flatten on parsing. --- src/xhtml.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xhtml.rs b/src/xhtml.rs index 76610936..8b9635e6 100644 --- a/src/xhtml.rs +++ b/src/xhtml.rs @@ -41,7 +41,7 @@ impl XhtmlIm { } /// Removes all unknown elements. - pub fn flatten(self) -> XhtmlIm { + fn flatten(self) -> XhtmlIm { let mut bodies = HashMap::new(); for (lang, body) in self.bodies { let children = body.children.into_iter().fold(vec![], |mut acc, child| { @@ -91,7 +91,7 @@ impl TryFrom for XhtmlIm { } } - Ok(XhtmlIm { bodies }) + Ok(XhtmlIm { bodies }.flatten()) } } @@ -237,7 +237,7 @@ impl Tag { let style = write_attr(get_style_string(style), "style"); format!("{}", style, children_to_html(children)) } - Tag::Strong { children } => format!("{}", children.into_iter().map(|child| child.to_html()).collect::>().join("")), + Tag::Strong { children } => format!("{}", children_to_html(children)), Tag::Ul { style, children } => { let style = write_attr(get_style_string(style), "style"); format!("{}", style, children_to_html(children))