summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-10-08 08:04:16 +0300
committerLars Wirzenius <liw@liw.fi>2023-10-09 18:03:16 +0300
commit8792812e8b070f9b44d01c8578d174bc977bd954 (patch)
treeab074af5a514556492318332f9e3c72b100a734f /src
parent478147c59de2547cb1e3e0a0cd5309c25f4453dc (diff)
downloadsubplot-8792812e8b070f9b44d01c8578d174bc977bd954.tar.gz
fix: add an HTML5 doctype to the serialized HTML
Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r--src/html.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/html.rs b/src/html.rs
index f863727..3e296d5 100644
--- a/src/html.rs
+++ b/src/html.rs
@@ -11,6 +11,8 @@ use std::fmt::Write as _;
use std::io::Write;
use std::path::{Path, PathBuf};
+const DOCTYPE: &str = "<!DOCTYPE html>";
+
/// A HTML page, consisting of a head and a body.
#[derive(Debug)]
pub struct HtmlPage {
@@ -48,7 +50,8 @@ impl HtmlPage {
let mut html = Element::new(ElementTag::Html);
html.push_child(Content::Elt(self.head.clone()));
html.push_child(Content::Elt(self.body.clone()));
- html.serialize()
+ let html = html.serialize()?;
+ Ok(format!("{}\n{}", DOCTYPE, html))
}
/// Try to write an HTML page as text into a file.