cut the md reader in half

This commit is contained in:
Mylloon 2023-04-14 12:25:14 +02:00
parent 274a6d567b
commit d2b520d9b6
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 11 additions and 7 deletions

View file

@ -5,7 +5,7 @@ use ramhorns::Content;
use crate::{
config::Config,
template::{read_md, File, Infos},
template::{read_md_file, File, Infos},
};
#[get("/portfolio")]
@ -28,13 +28,13 @@ pub fn get_page(config: Config) -> String {
// Get bots apps
let mut bots_apps = Vec::new();
for entry in glob(&format!("{projects_dir}/bots/*{ext}")).unwrap() {
bots_apps.push(read_md(&entry.unwrap().to_string_lossy()));
bots_apps.push(read_md_file(&entry.unwrap().to_string_lossy()));
}
// Get perso apps
let mut perso_apps = Vec::new();
for entry in glob(&format!("{projects_dir}/perso/*{ext}")).unwrap() {
perso_apps.push(read_md(&entry.unwrap().to_string_lossy()));
perso_apps.push(read_md_file(&entry.unwrap().to_string_lossy()));
}
config.tmpl.render(
@ -42,7 +42,7 @@ pub fn get_page(config: Config) -> String {
PortfolioTemplate {
bots_app: bots_apps,
persos_app: perso_apps,
univ_content: read_md(&format!("{projects_dir}/univ{ext}")).content,
univ_content: read_md_file(&format!("{projects_dir}/univ{ext}")).content,
},
Infos {
page_title: Some("Portfolio".to_string()),

View file

@ -71,12 +71,16 @@ pub struct File {
pub content: String,
}
pub fn read_md(filename: &str) -> File {
pub fn read_md_file(filename: &str) -> File {
// Read markdown file
let mut text = fs::read_to_string(filename).unwrap();
let text = fs::read_to_string(filename).unwrap();
read_md(&text)
}
pub fn read_md(raw_text: &str) -> File {
// Transform LaTeX to MathML
text = latex2mathml::replace(&text).unwrap();
let text = latex2mathml::replace(raw_text).unwrap();
let parse_option = markdown::ParseOptions {
constructs: markdown::Constructs {