Basic cours support #44

Merged
Anri merged 67 commits from cours into main 2024-04-01 18:11:49 +02:00
Showing only changes of commit 1815a39fa6 - Show all commits

View file

@ -202,9 +202,9 @@ fn fix_local_img(path: &str, html: String) -> String {
RewriteStrSettings { RewriteStrSettings {
element_content_handlers: vec![element!("img", |el| { element_content_handlers: vec![element!("img", |el| {
if let Some(src) = el.get_attribute("src") { if let Some(src) = el.get_attribute("src") {
if let Some(img_src) = Path::new(path).parent() { let img_src = Path::new(path).parent().unwrap();
let img_path = img_src.join(src); let img_path = img_src.join(src);
let file = fs::read_to_string(&img_path).unwrap(); if let Ok(file) = fs::read_to_string(&img_path) {
let image = general_purpose::STANDARD.encode(file); let image = general_purpose::STANDARD.encode(file);
el.set_attribute( el.set_attribute(