handle non-svg images

This commit is contained in:
Mylloon 2024-12-12 18:30:17 +01:00
parent d452d28854
commit d3d99fd226
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -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();
}