have a unique header id per file
currently this break anchors as id != links
This commit is contained in:
parent
7752363039
commit
41311c05ed
1 changed files with 19 additions and 2 deletions
|
@ -59,7 +59,10 @@ pub fn get_options(path: Option<FilePath>, 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::<Vec<_>>()
|
||||
.join("/"),
|
||||
path: new_path.last().unwrap_or("").to_string(),
|
||||
}),
|
||||
metadata_type,
|
||||
);
|
||||
|
||||
options.extension.footnotes = false;
|
||||
let data = read_md(
|
||||
&path.from(&img_path),
|
||||
|
|
Loading…
Reference in a new issue