etiennebacher / altdoc

Alternative to pkgdown to document R packages
https://altdoc.etiennebacher.com
Other
65 stars 9 forks source link

Quarto adds `.png` file extension automatically and incorrectly #178

Closed grantmcdermott closed 9 months ago

grantmcdermott commented 9 months ago

First discovered over at plot2. You can see that my r-universe badge on the README is failing.

It looks like the badge error is due to altdoc re-rendering the README file and then appending ".png" on the badge link, i.e. instead of

https://grantmcdermott.r-universe.dev/badges/plot2

we get

https://grantmcdermott.r-universe.dev/badges/plot2.png

I can fix it locally by knitting the README file manually, but then I'm worried that the R-chunk knitted PNG images won't appear (since these are assigned a new path, right?)

vincentarelbundock commented 9 months ago

Ah thanks for this. I'll look into when I find time. Almost definitely my fault.

vincentarelbundock commented 9 months ago

Fixed in altdoc, opened a PR on plot2 to update the website accordingly.

grantmcdermott commented 9 months ago

Thanks @vincentarelbundock. Just merged but I think there's still an error: The trailing ".png," shouldn't be there at the end.

In other words, it should be this... https://grantmcdermott.r-universe.dev/badges/plot2

... not this. https://grantmcdermott.r-universe.dev/badges/plot2.png

etiennebacher commented 9 months ago

Problem is that quarto automatically adds this .png extension.

foo.Rmd:

[![R-universe status
badge](https://grantmcdermott.r-universe.dev/badges/plot2)](https://grantmcdermott.r-universe.dev)

After quarto::quarto_render("foo.Rmd", output_format = "markdown"), this becomes:

---
toc-title: Table of contents
---

[![R-universe status
badge](https://grantmcdermott.r-universe.dev/badges/plot2.png)](https://grantmcdermott.r-universe.dev)
etiennebacher commented 9 months ago

https://github.com/quarto-dev/quarto-cli/issues/6092#issuecomment-1618063261

Looks like we can't pass this argument to quarto_render() so we need to manually add it to the preamble.

vincentarelbundock commented 9 months ago

Fixed here by adding a line to the preamble we store in altdoc/ and making .import_readme() use it: https://github.com/etiennebacher/altdoc/pull/190

This won't fix it when README is a .Rmd file. I'm not sure if there's a similar option there. If there is, all we'd need to do is add the option to inst/preamble_vignettes_rmd.yml

vincentarelbundock commented 9 months ago

Badge looks good on the rendered plot2 site: https://grantmcdermott.com/plot2/#/

grantmcdermott commented 6 months ago

Sorry to resurrect an old issue, but this is failing for me again on (the new) tinyplot website: https://grantmcdermott.com/tinyplot/

We moved to Quarto a while back and AFAICT it's been broken since. (I've been manually editing the rendered README.md file to at least get the GitHub landing page looking good.)

vincentarelbundock commented 6 months ago

I don't there's anything altdoc should do about this. Any solution would be very hack-y and error prone.

The problem is that Quarto tries to be "helpful", but that its automagic feature breaks on R-universe links.

Details: Quarto inserts .png automatically when using the []() syntax for images and when there is no extension to the image path. R-universe badges are hosted on a website with a link without extension.

I just merged a pull request to tinyplot to fix this, but simply using a normal HTML link tag instead of markdown syntax.

etiennebacher commented 6 months ago

Note that as of quarto 1.4 (the R package, not just the general software), we can use the quarto_args argument in quarto_render() to pass arguments that are not individually supported. For example, my reprex above can be fixed by calling quarto::quarto_render("foo.qmd", output_format = "markdown", quarto_args = c("--default-image-extension", "")). I think that would allow us to greatly simplify the internals by removing all the "custom preamble" stuff