From eafbc710ff0f6d2d11065a01145505f15497fc3a Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Thu, 29 Aug 2024 21:47:55 +0200 Subject: [PATCH] make alt text optional in image macro --- src/convert.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/convert.rs b/src/convert.rs index 37eb5db..b901169 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -44,7 +44,9 @@ pub fn convert_document(markdown: &str) -> String { } if let Some(img_info) = line.strip_prefix("==image:") { - let (src, alt) = img_info.split_once(':').unwrap(); + let mut attributes = img_info.split(':'); + let src = attributes.next().unwrap(); + let alt = attributes.next().unwrap_or_else(|| &"\"\""); html += &format!("{alt}\n"); continue; }