diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-06-10 22:20:13 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-06-10 22:20:13 +0200 |
commit | 0e147a780e74b54afbd56ff7438077d855d5c1c2 (patch) | |
tree | 25296b0370513c757416ea6d5e7258b4069b1307 /src | |
parent | 17d160e5f9cdd4e46b0ab08cf56eaedd8943d885 (diff) | |
download | macroblog.rs-0e147a780e74b54afbd56ff7438077d855d5c1c2.tar.gz macroblog.rs-0e147a780e74b54afbd56ff7438077d855d5c1c2.tar.bz2 macroblog.rs-0e147a780e74b54afbd56ff7438077d855d5c1c2.zip |
ref: Move from HTML to MD
Keep and write in html is pain, so I'm rendering md as html.
Diffstat (limited to 'src')
-rw-r--r-- | src/blog.rs | 8 |
1 files changed, 6 insertions, 2 deletions
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 { |