From d3d99fd2267a6ece72ab490c6ff7165545286d90 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 12 Dec 2024 18:30:17 +0100 Subject: [PATCH] handle non-svg images --- src/utils/markdown.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/markdown.rs b/src/utils/markdown.rs index c72528e..511afda 100644 --- a/src/utils/markdown.rs +++ b/src/utils/markdown.rs @@ -186,14 +186,15 @@ fn fix_images_and_integration( .unwrap() .to_string(); - if let Ok(file) = fs::read_to_string(&img_path) { + if let Ok(file_contents) = fs::read(&img_path) { let mime = mime_guess::from_path(&img_path).first_or_octet_stream(); if recursive && mime == "text/markdown" { + let file_str = String::from_utf8_lossy(&file_contents).into_owned(); let mut options = get_options(Some(path.clone()), metadata_type); options.extension.footnotes = false; let data = read_md( &path.from(&img_path), - &file, + &file_str, metadata_type, Some(options), false, @@ -203,7 +204,7 @@ fn fix_images_and_integration( // Store the metadata for later merging additional_metadata.push(data.metadata); } else { - let image = general_purpose::STANDARD.encode(file); + let image = general_purpose::STANDARD.encode(&file_contents); el.set_attribute("src", &format!("data:{mime};base64,{image}")) .unwrap(); }