diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-10-08 08:06:15 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-10-09 18:20:50 +0300 |
commit | 54b70a0eaba4272f60a90386a0ca693bf30887f3 (patch) | |
tree | 84939921b80d16887fce525dc04d385f9454a3a2 /src | |
parent | 8792812e8b070f9b44d01c8578d174bc977bd954 (diff) | |
download | subplot-54b70a0eaba4272f60a90386a0ca693bf30887f3.tar.gz |
fix: have only one <body> in a serialized HTML page
Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r-- | src/html.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/html.rs b/src/html.rs index 3e296d5..2562b9b 100644 --- a/src/html.rs +++ b/src/html.rs @@ -49,7 +49,9 @@ impl HtmlPage { pub fn serialize(&self) -> Result<String, HtmlError> { let mut html = Element::new(ElementTag::Html); html.push_child(Content::Elt(self.head.clone())); - html.push_child(Content::Elt(self.body.clone())); + let mut body = Element::new(ElementTag::Body); + body.push_child(Content::Elt(self.body.clone())); + html.push_child(Content::Elt(body)); let html = html.serialize()?; Ok(format!("{}\n{}", DOCTYPE, html)) } @@ -85,7 +87,7 @@ pub fn parse(filename: &Path, markdown: &str) -> Result<Element, HtmlError> { let p = Parser::new_ext(markdown, options).into_offset_iter(); let linecol = LineColLookup::new(markdown); let mut stack = Stack::new(); - stack.push(Element::new(ElementTag::Body)); + stack.push(Element::new(ElementTag::Div)); for (event, loc) in p { trace!("event {:?}", event); let (line, col) = linecol.get(loc.start); |