mod display;
use crate::HtmlElement;
use std::fmt::{Display, Formatter};
#[derive(Clone, PartialEq, Eq)]
pub enum HtmlNode {
Doctype(DocType),
Comment(String),
Text(String),
Element(HtmlElement),
ProcessingInstruction(ProcessingInstruction),
}
impl Display for HtmlNode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
HtmlNode::Doctype(_) => write!(f, "<!DOCTYPE html>"),
HtmlNode::Comment(comment) => write!(f, "<!-- {} -->", comment),
HtmlNode::Text(text) => write!(f, "{}", text),
HtmlNode::Element(element) => write!(f, "{}", element),
HtmlNode::ProcessingInstruction(pi) => write!(f, "<?{} {}?>", pi.target, pi.data),
}
}
}
impl Default for HtmlNode {
fn default() -> Self {
Self::Element(HtmlElement::default())
}
}
#[derive(Clone, PartialEq, Eq)]
pub struct DocType {
pub name: String,
pub public_id: String,
pub system_id: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProcessingInstruction {
pub target: String,
pub data: String,
}