html: add alt text support for images
This commit is contained in:
parent
40b0cae06e
commit
f859437560
13
src/html.rs
13
src/html.rs
|
@ -74,9 +74,16 @@ impl Traverser for Handler {
|
||||||
};
|
};
|
||||||
|
|
||||||
if link.is_image() {
|
if link.is_image() {
|
||||||
// FIXME: needs alt text support
|
if let Some(Some(caption)) = link.caption().map(|c| c.value()) {
|
||||||
self.0
|
self.0.push_str(format!(
|
||||||
.push_str(format!("<img src=\"{}\">", HtmlEscape(&path)));
|
r#"<img src="{}" alt="{}">"#,
|
||||||
|
HtmlEscape(&path),
|
||||||
|
HtmlEscape(caption.trim())
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
self.0
|
||||||
|
.push_str(format!("<img src=\"{}\">", HtmlEscape(&path)));
|
||||||
|
}
|
||||||
return ctx.skip();
|
return ctx.skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue