diff --git a/src/utils/markdown.rs b/src/utils/markdown.rs index e051a12..f0cacb9 100644 --- a/src/utils/markdown.rs +++ b/src/utils/markdown.rs @@ -59,7 +59,10 @@ pub fn get_options(path: Option, metadata_type: MType) -> ComrakOption .autolink(true) .tasklist(true) .superscript(true) - .header_ids(String::new()) + .header_ids(match path.clone() { + Some(fp) => format!("{}-", fp.path.get(..fp.path.len() - 3).unwrap_or_default()), + None => String::new(), + }) .footnotes(true) .description_lists(true) .front_matter_delimiter("---".into()) @@ -220,7 +223,21 @@ fn fix_images_and_integration( 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); + + // Find a ok-ish path + let new_path = img_path.split('/'); + let mut options = get_options( + Some(FilePath { + base: new_path + .clone() + .take(new_path.clone().count() - 1) + .collect::>() + .join("/"), + path: new_path.last().unwrap_or("").to_string(), + }), + metadata_type, + ); + options.extension.footnotes = false; let data = read_md( &path.from(&img_path),