html_ast/node/
display.rs

1use super::*;
2
3impl Default for HtmlNode {
4    fn default() -> Self {
5        Self::Element(HtmlElement::default())
6    }
7}
8impl Display for HtmlNode {
9    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
10        match self {
11            HtmlNode::Doctype(_) => write!(f, "<!DOCTYPE html>"),
12            HtmlNode::Comment(comment) => write!(f, "<!-- {} -->", comment),
13            HtmlNode::Text(text) => {
14                write!(f, "{}", text)
15            }
16            HtmlNode::Element(element) => write!(f, "{}", element),
17            HtmlNode::ProcessingInstruction(pi) => write!(f, "<?{} {}?>", pi.target, pi.data),
18        }
19    }
20}