Embedding {learnr} in {distill}

How to share a {learnr} lesson within a {distill} website page
R
Author

Harvey

Published

November 30, 2021

{learnr} is an R package from RStudio which uses R Markdown to create interactive tutorials. Once completed, the tutorial can be published via shiny server or RStudio Connect. As a {learnr} markdown file contains its own yaml header it cannot be directly included in a website built by distill. It can, however, be included if it is hosted (shiny server or RStudio Connect) and embedded using iframe

```{r, layout="l-screen-inset"}
htmltools::tags$iframe(src = "<RSCONNECT URL>", height = "600px", width = "100%", `data-external` = "1")
```

where is the url of the {learnr} tutorial. The use of data-external is related to the way that pandoc processes iframe tags (see https://community.rstudio.com/t/insert-raw-html-iframe-into-rmarkdown/94334 and https://pandoc.org/MANUAL.html#option–self-contained).