diff --git a/libimagentrymarkdown/src/error.rs b/libimagentrymarkdown/src/error.rs index 7f956801..f3d81d1e 100644 --- a/libimagentrymarkdown/src/error.rs +++ b/libimagentrymarkdown/src/error.rs @@ -1,6 +1,6 @@ generate_error_module!( generate_error_types!(MarkdownError, MarkdownErrorKind, - MarkdownParsingError => "Markdown parsing error" + MarkdownRenderError => "Markdown render error" ); ); diff --git a/libimagentrymarkdown/src/html.rs b/libimagentrymarkdown/src/html.rs index 4e278fab..b350f34f 100644 --- a/libimagentrymarkdown/src/html.rs +++ b/libimagentrymarkdown/src/html.rs @@ -1,10 +1,21 @@ +use hoedown::{Markdown, Html as MdHtml}; +use hoedown::renderer::html::Flags as HtmlFlags; +use hoedown::renderer::Render; + use result::Result; use error::MarkdownErrorKind; +use libimagerror::into::IntoError; pub type HTML = String; pub fn to_html(buffer: &str) -> Result { - unimplemented!() + let md = Markdown::new(buffer); + let mut html = MdHtml::new(HtmlFlags::empty(), 0); + html.render(&md) + .to_str() + .map(String::from) + .map_err(Box::new) + .map_err(|e| MarkdownErrorKind::MarkdownRenderError.into_error_with_cause(e)) } pub mod iter {