From d0caa08819d74999f7950827755f98d9be564cfe Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 14 Dec 2024 02:24:24 +0100 Subject: [PATCH] fix crash --- src/utils/markdown.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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()