Markdown syntax for resizing images in README.md breaks on pkgdown site
DeepanshKhurana opened this issue · comments
Markdown offers an image resizing mechanism with the following syntax.
![alt_text](man/figures/image.png =WIDTHxHEIGHT)
When used in a markdown document, this resizing works great. But when this same README.md is used by pkgdown, the path it will create is http://site.url/reference/figures/image.png%20=WIDTHxHEIGHT
.
This is a problem because the image exists at http://site.url/reference/figures/image.png
.
It seems a quick and easy fix is to resize the images before putting them in but I wonder if this can be fixed on the pkgdown
side of things anyway.
Of course, pkgdown
does raise a warning for this which should be enough to at least investigate this issue but it seems a bit counter-intuitive when the images exist and only the path gets broken.
Essentially, something similar to the following could be called in the correct place (before the markdown is converted to HTML).
strip_image_resize_params <- function(image_path) {
gsub("\\s*=\\d+x\\d+", "", image_path)
}
That doens't look like any markdown syntax I'm familiar with, and doesn't look like it's supported by pandoc: https://pandoc.org/MANUAL.html#images. That makes it very difficult to support it in pkgdown.
Ah, so the better thing would be to raise it with pandoc
instead. I also failed to mention that this was a document on AzureDevOps and I've seen this implementation work in some but not all places. My bad for not including a reference.
I'll check if I can get pandoc
to support this, and maybe then it can come downstream.
In any case, thanks for the reply!