cut the md reader in half
This commit is contained in:
parent
274a6d567b
commit
d2b520d9b6
2 changed files with 11 additions and 7 deletions
|
@ -5,7 +5,7 @@ use ramhorns::Content;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::Config,
|
config::Config,
|
||||||
template::{read_md, File, Infos},
|
template::{read_md_file, File, Infos},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[get("/portfolio")]
|
#[get("/portfolio")]
|
||||||
|
@ -28,13 +28,13 @@ pub fn get_page(config: Config) -> String {
|
||||||
// Get bots apps
|
// Get bots apps
|
||||||
let mut bots_apps = Vec::new();
|
let mut bots_apps = Vec::new();
|
||||||
for entry in glob(&format!("{projects_dir}/bots/*{ext}")).unwrap() {
|
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
|
// Get perso apps
|
||||||
let mut perso_apps = Vec::new();
|
let mut perso_apps = Vec::new();
|
||||||
for entry in glob(&format!("{projects_dir}/perso/*{ext}")).unwrap() {
|
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(
|
config.tmpl.render(
|
||||||
|
@ -42,7 +42,7 @@ pub fn get_page(config: Config) -> String {
|
||||||
PortfolioTemplate {
|
PortfolioTemplate {
|
||||||
bots_app: bots_apps,
|
bots_app: bots_apps,
|
||||||
persos_app: perso_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 {
|
Infos {
|
||||||
page_title: Some("Portfolio".to_string()),
|
page_title: Some("Portfolio".to_string()),
|
||||||
|
|
|
@ -71,12 +71,16 @@ pub struct File {
|
||||||
pub content: String,
|
pub content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_md(filename: &str) -> File {
|
pub fn read_md_file(filename: &str) -> File {
|
||||||
// Read markdown 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
|
// Transform LaTeX to MathML
|
||||||
text = latex2mathml::replace(&text).unwrap();
|
let text = latex2mathml::replace(raw_text).unwrap();
|
||||||
|
|
||||||
let parse_option = markdown::ParseOptions {
|
let parse_option = markdown::ParseOptions {
|
||||||
constructs: markdown::Constructs {
|
constructs: markdown::Constructs {
|
||||||
|
|
Loading…
Reference in a new issue