use crate::attributes::Attributes;
#[derive(Debug, Default)]
#[non_exhaustive]
pub enum HtmlVersion {
#[default]
HTML5,
HTML4,
XHTML1_0,
XHTML1_1,
}
impl HtmlVersion {
pub fn doctype(&self) -> &'static str {
match self {
Self::HTML5 => "<!DOCTYPE html>",
Self::HTML4 => {
r#"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/HTML4/loose.dtd">"#
}
Self::XHTML1_0 => {
r#"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"#
}
Self::XHTML1_1 => {
r#"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">"#
}
}
}
pub fn html_attrs(&self) -> Attributes {
match self {
Self::XHTML1_0 => Attributes::from([("xmlns", "http://www.w3.org/1999/xhtml")]),
Self::XHTML1_1 => Attributes::from([
("xmlns", "http://www.w3.org/1999/xhtml"),
("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"),
(
"xsi:schemaLocation",
"http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd",
),
("xml:lang", "en"),
]),
_ => Attributes::default(),
}
}
}