From 0e147a780e74b54afbd56ff7438077d855d5c1c2 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Fri, 10 Jun 2022 22:20:13 +0200 Subject: ref: Move from HTML to MD Keep and write in html is pain, so I'm rendering md as html. --- src/blog.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/blog.rs b/src/blog.rs index 0fa9543..c877303 100644 --- a/src/blog.rs +++ b/src/blog.rs @@ -1,4 +1,5 @@ use chrono::NaiveDate; +use pulldown_cmark::{html, Options, Parser}; use regex::Regex; use rust_embed::RustEmbed; use sailfish::TemplateOnce; @@ -60,8 +61,11 @@ impl BlogEntry { fn get_file_content(path: &str) -> String { let buffer = PostAsset::get(path).unwrap().data.into_owned(); - - return String::from_utf8(buffer).unwrap(); + let md = String::from_utf8(buffer).unwrap(); + let parser = Parser::new_ext(&md, Options::empty()); + let mut html_output = &mut String::new(); + html::push_html(&mut html_output, parser); + return html_output.to_string(); } pub fn render_post_page(path: &String) -> String { -- cgit v1.2.3