From a7fb72e1a4a5f371326fe1efe8aeffb75bde243d Mon Sep 17 00:00:00 2001 From: bnewbold Date: Thu, 5 Jan 2017 00:24:36 -0800 Subject: switch from 'markdown' to 'pulldown-cmark' for markdown rendering --- src/bin/mt-webface.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bin/mt-webface.rs b/src/bin/mt-webface.rs index ccf4660..3d17bb5 100644 --- a/src/bin/mt-webface.rs +++ b/src/bin/mt-webface.rs @@ -3,7 +3,7 @@ extern crate getopts; extern crate pencil; extern crate modelthing; extern crate env_logger; -extern crate markdown; +extern crate pulldown_cmark; #[macro_use] extern crate log; @@ -55,13 +55,18 @@ fn model_view(r: &mut Request) -> PencilResult { let model_path = Path::new(namespace).join(model_slug); match modelthing::load_model_entry(model_path.as_path()) { Ok(me) => { + let mut markdown_html = String::new(); + let p = pulldown_cmark::Parser::new_ext( + &me.markdown, + pulldown_cmark::Options::empty()); + pulldown_cmark::html::push_html(&mut markdown_html, p); let mut context = BTreeMap::new(); context.insert("namespace".to_string(), namespace.to_string()); context.insert("model_slug".to_string(), model_slug.to_string()); context.insert("model_name".to_string(), me.ast.name.clone()); context.insert("model_description".to_string(), me.ast.description.clone().unwrap_or("".to_string())); - context.insert("markdown_html".to_string(), markdown::to_html(&me.markdown)); - context.insert("markdown".to_string(), me.markdown); + context.insert("markdown_html".to_string(), markdown_html); + context.insert("markdown".to_string(), me.markdown.clone()); context.insert("modelica".to_string(), format!("{:?}", me.ast)); r.app.render_template("model_view.html", &context) }, -- cgit v1.2.3