summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-06-15 07:56:32 +0300
committerLars Wirzenius <liw@liw.fi>2023-06-15 07:56:32 +0300
commit8802069892c3835181cb506d0deba91eacce225a (patch)
tree3583752bf424a34c0cc36278cfdb9476adcdd20a /src/doc.rs
parent9f2198d7c6d323b04d2d6a2ee6bf1cc421a91de5 (diff)
downloadsubplot-8802069892c3835181cb506d0deba91eacce225a.tar.gz
refactor: change Document::to_html to return a Result
HTML generation uses write!, which can fail, so to_html must return a Result. Sponsored-by: author
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/doc.rs b/src/doc.rs
index e218020..6fbf497 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -153,7 +153,7 @@ impl Document {
}
/// Return Document as an HTML page serialized into HTML text
- pub fn to_html(&mut self, date: &str) -> String {
+ pub fn to_html(&mut self, date: &str) -> Result<String, SubplotError> {
let mut head = Element::new(crate::html::ElementTag::Head);
let mut title = Element::new(crate::html::ElementTag::Title);
title.push_child(crate::html::Content::Text(self.meta().title().into()));
@@ -166,7 +166,7 @@ impl Document {
body.push_child(Content::Elt(md.root_element().clone()));
}
let page = HtmlPage::new(head, body);
- page.serialize().unwrap() // FIXME
+ page.serialize().map_err(SubplotError::ParseMarkdown)
}
fn typeset_meta(&self) -> Element {