Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown syntax for resizing images in README.md breaks on pkgdown site #2389

Closed
DeepanshKhurana opened this issue Dec 22, 2023 · 3 comments
Closed

Comments

@DeepanshKhurana
Copy link

DeepanshKhurana commented Dec 22, 2023

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.

@DeepanshKhurana
Copy link
Author

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)
}

@hadley
Copy link
Member

hadley commented Apr 11, 2024

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.

@hadley hadley closed this as completed Apr 11, 2024
@DeepanshKhurana
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants