From 0b98ae0079d20964198ee3577a85bc429aa91c81 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Fri, 7 Feb 2025 21:08:30 +0400 Subject: [PATCH] fix: images --- src/markdown.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/markdown.rs b/src/markdown.rs index 8a14d85..d326fe7 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -152,6 +152,10 @@ fn render_markdown<'md>(src: &'md str, mut p: ParserVars<'md>) -> std::io::Resul } Image { dest_url, .. } => { + p.html.write_fmt(format_args!( + "
\"Image\"
", + dest_url + ))?; p.links.push(GmiLink::from_url(dest_url)); p.state = State::Link; } @@ -240,12 +244,13 @@ fn render_markdown<'md>(src: &'md str, mut p: ParserVars<'md>) -> std::io::Resul p.html.write_all(b"")?; write_inline(&mut p, "~")?; } - Link | Image => { - p.gmi.write_fmt(format_args!( - "{}[{}]", // example[1] ...\r\n => https://... [1]: example - p.links.last().unwrap().title, - p.links.len(), - ))?; + Link => { + p.html.write_all(b"")?; + p.gmi.write_fmt(format_args!("[{}]", p.links.len()))?; + } + Image => { + p.html.write_all(b"
")?; + p.gmi.write_fmt(format_args!("[{}]", p.links.len()))?; } TableHead => p.html.write_all(b"")?, TableRow => p.html.write_all(b"")?, @@ -368,10 +373,9 @@ fn write_inline(p: &mut ParserVars, text: &str) -> std::io::Result<()> { State::Footnote => { p.notes.last_mut().unwrap().content.push_str(text); } - _ => { - p.gmi.write_all(text.as_bytes())?; - } + _ => {} } + p.gmi.write_all(text.as_bytes())?; Ok(()) }