fix: images
This commit is contained in:
parent
7045fb8625
commit
0b98ae0079
1 changed files with 13 additions and 9 deletions
|
@ -152,6 +152,10 @@ fn render_markdown<'md>(src: &'md str, mut p: ParserVars<'md>) -> std::io::Resul
|
||||||
}
|
}
|
||||||
|
|
||||||
Image { dest_url, .. } => {
|
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.links.push(GmiLink::from_url(dest_url));
|
||||||
p.state = State::Link;
|
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>")?;
|
p.html.write_all(b"</s>")?;
|
||||||
write_inline(&mut p, "~")?;
|
write_inline(&mut p, "~")?;
|
||||||
}
|
}
|
||||||
Link | Image => {
|
Link => {
|
||||||
p.gmi.write_fmt(format_args!(
|
p.html.write_all(b"</a>")?;
|
||||||
"{}[{}]", // example[1] ...\r\n => https://... [1]: example
|
p.gmi.write_fmt(format_args!("[{}]", p.links.len()))?;
|
||||||
p.links.last().unwrap().title,
|
}
|
||||||
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>")?,
|
TableHead => p.html.write_all(b"</tr></thead><tbody>")?,
|
||||||
TableRow => p.html.write_all(b"</tr>")?,
|
TableRow => p.html.write_all(b"</tr>")?,
|
||||||
|
@ -368,10 +373,9 @@ fn write_inline(p: &mut ParserVars, text: &str) -> std::io::Result<()> {
|
||||||
State::Footnote => {
|
State::Footnote => {
|
||||||
p.notes.last_mut().unwrap().content.push_str(text);
|
p.notes.last_mut().unwrap().content.push_str(text);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {}
|
||||||
|
}
|
||||||
p.gmi.write_all(text.as_bytes())?;
|
p.gmi.write_all(text.as_bytes())?;
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue