diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-06-15 07:56:32 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-06-15 07:56:32 +0300 |
commit | 8802069892c3835181cb506d0deba91eacce225a (patch) | |
tree | 3583752bf424a34c0cc36278cfdb9476adcdd20a /src/doc.rs | |
parent | 9f2198d7c6d323b04d2d6a2ee6bf1cc421a91de5 (diff) | |
download | subplot-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.rs | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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 { |