[R-pkg-devel] Rmarkdown package vignette that reference online images: how to fail gracefully?
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Wed Oct 4 10:34:08 CEST 2023
On Tue, 3 Oct 2023 14:52:26 -0700
Vinh Nguyen <vinhdizzo using gmail.com> wrote:
> Could not fetch
> https://live.staticflickr.com/65535/52281215570_5f9cc90a12_o.png
This is Pandoc failing to bundle external resources from the final
Markdown file, not your R code.
> Error: processing vignette
> 'Ex-04-Webscraping-Online-Data-Files.Rmd' failed with diagnostics:
> pandoc document conversion failed with error 61
My psychic debugging powers tell me that this is the vignette you're
having problems with:
https://github.com/vinhdizzo/IRexamples/blob/main/vignettes/Ex-04-Webscraping-Online-Data-Files.Rmd
If you look at the vignette as it is on CRAN, you can see that the
images aren't actually loaded from live.staticflickr.com, but are
included as base64 PNG blobs in the HTML file. This is much less
efficient than a plain PNG file. I think that your package will become
smaller if you disable this bundling and include the original PNG files
in your package. You may be able to squeeze some more savings by using
pngcrush / optipng to compress the images further.
The parameter responsible for this base64 encoding is called
self_contained, which defaults to TRUE in the rmarkdown::html_document
format, which prettydoc::html_pretty inherits from. Set it to FALSE in
the YAML header of the vignette.
Note that some other scripts and CSS files may be loaded from external
sources if you do that. As a user, I would prefer this not to be the
case, but I don't know enough about rmarkdown to set your vignette up
to bundle everything except the images.
--
Best regards,
Ivan
More information about the R-package-devel
mailing list