`knitr::include_url` produces inline frame without images

Viewed 186

Expected

According to the rmarkdown cookbook, using knitr::include_url should produce an inline frame of the webpage (note that it works and contains images):

enter image description here

Observed

But when I do the exact same thing in HTML document, I see no images in my inline frame, and I am not sure why:

enter image description here

Details

In case it helps, here are some more details:

YAML for my document

---
output: html_document
---

System details

 version  R version 4.0.5 (2021-03-31)
 os       macOS Mojave 10.14.6        
 system   x86_64, darwin17.0          
 ui       RStudio 
2 Answers

This is due to a change in a recent version of Pandoc (not that recent but a few months ago) that it will embed URLs as base64 data. I just patched knitr to change this behavior. You can try the dev version of knitr:

remotes::install_github('yihui/knitr')

For those who can't update to last knitr version for any reason, you can fix this by adding the attributes yourself to the chunk using out.extra chunk option.

```{r, out.extra="data-external=1"}
knitr::include_url("https://yihui.org/knitr/")
```

Just sharing this workaround in case updating to dev knitr is a problem and one wants to wait for CRAN version.

Related