diff --git a/src/utils/markdown.rs b/src/utils/markdown.rs index 78160db..66323f0 100644 --- a/src/utils/markdown.rs +++ b/src/utils/markdown.rs @@ -203,8 +203,9 @@ fn fix_headers_ids(html: &str) -> String { html, RewriteStrSettings { element_content_handlers: vec![element!("a[href^='#']", |el| { - el.set_attribute("href", &format!("#{}", el.get_attribute("id").unwrap())) - .unwrap(); + if let Some(id) = el.get_attribute("id") { + el.set_attribute("href", &format!("#{id}")).unwrap(); + }; Ok(()) })], ..RewriteStrSettings::default()