pub fn tag_optimize<'a>(content: Vec<HtmlTag<'a>>) -> Vec<HtmlTag<'a>>
Expand description
A tag “completer” that fill in some missing tags allowed by html specification
Some html tags are allowed to be “inferred” in specific location; however, our parser does not allow this. Thus, this function will “fix” those tags.
This function is currently significantly incomplete compared to html specification.
let parsed = ElementContent::parse(tag_optimize(HtmlTag::parse(
r#"<img abc>"#,
)));
assert_eq!(parsed,
Ok(vec![
ElementContent::HtmlElement(Box::new(HtmlElement {
name: "img",
attributes: vec![("abc", None)],
tag_state: ElementTagState::BothTag,
content: Vec::new(),
}))])
);