1
0
Fork 0
mirror of https://github.com/lise-henry/crowbook synced 2024-05-25 02:46:08 +02:00

Support different display for inline/standalone images in HTML

This commit is contained in:
Elisabeth Henry 2016-09-11 02:21:21 +02:00
parent 873c530b82
commit 813c4e738e
3 changed files with 19 additions and 9 deletions

View File

@ -418,13 +418,23 @@ impl<'a> HtmlRenderer<'a> {
},
Token::Image(ref url, ref title, ref alt)
| Token::StandaloneImage(ref url, ref title, ref alt) => {
let content = self.render_vec(alt);
let url = self.handler.map_image(Cow::Borrowed(url));
format!("<img src = \"{}\" title = \"{}\" alt = \"{}\" />",
url,
title,
content)
},
let content = self.render_vec(alt);
let url = self.handler.map_image(Cow::Borrowed(url));
if let Token::Image(_, _, _) = *token {
format!("<img src = \"{}\" title = \"{}\" alt = \"{}\" />",
url,
title,
content)
} else {
format!("<div class = \"image\">
<img src = \"{}\" title = \"{}\" alt = \"{}\" />
</div>",
url,
title,
content)
}
},
Token::Table(_, ref vec) => format!("<div class = \"table\">
<table>\n{}
</table>

View File

@ -72,7 +72,7 @@ h2.author {
width: 100%;
}
p img {
.image img {
width: 80%;
}

View File

@ -110,7 +110,7 @@ nav {
}
/* Improving readability for the HTML format only */
p, blockquote, li {
p, blockquote, li, .image {
margin-right: auto;
max-width: 33em;
}