make alt text optional in image macro
This commit is contained in:
parent
21c681fc8a
commit
eafbc710ff
1 changed files with 3 additions and 1 deletions
|
@ -44,7 +44,9 @@ pub fn convert_document(markdown: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(img_info) = line.strip_prefix("==image:") {
|
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!("<img loading=\"lazy\" src={src} alt={alt} title={alt}></img>\n");
|
html += &format!("<img loading=\"lazy\" src={src} alt={alt} title={alt}></img>\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue