fix: images

This commit is contained in:
DarkCat09 2025-02-07 21:08:30 +04:00
parent 7045fb8625
commit 0b98ae0079
Signed by: DarkCat09
GPG key ID: BD3CE9B65916CD82

View file

@ -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!(
"<figure><img src=\"{}\" alt=\"Image\"><figcaption>",
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"</s>")?;
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"</a>")?;
p.gmi.write_fmt(format_args!("[{}]", p.links.len()))?;
}
Image => {
p.html.write_all(b"</figcaption></figure>")?;
p.gmi.write_fmt(format_args!("[{}]", p.links.len()))?;
}
TableHead => p.html.write_all(b"</tr></thead><tbody>")?,
TableRow => p.html.write_all(b"</tr>")?,
@ -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(())
}