diff --git a/vignettes/starwars-dynamic.Rmd b/vignettes/starwars-dynamic.Rmd new file mode 100644 index 0000000..5f9e955 --- /dev/null +++ b/vignettes/starwars-dynamic.Rmd @@ -0,0 +1,106 @@ +--- +title: "Star Wars films (dynamic HTML)" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Star Wars films (dynamic HTML)} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, eval = FALSE, echo = FALSE} +library(magrittr) +crawl_html <- function(x) { + x %>% + gsub("\r", "", .) %>% + gsub("\n\n", "
", .) %>% + gsub("\n", " ", .) %>% + paste0("
", ., "
") +} + +fields <- c("episode_id", "title", "release_date", "director", "opening_crawl") +repurrrsive::sw_films |> + lapply(\(film) film[fields]) |> + lapply(function(film) { + film$opening_crawl <- crawl_html(film$opening_crawl) + film + }) |> + jsonlite::write_json("vignettes/starwars.json", pretty = TRUE, auto_unbox = TRUE) +``` + +This vignette contains some dynamic generated data about the Star Wars films for use in rvest examples and vignettes. + +```{=html} + +``` +::: {#moviesInfo} +::: diff --git a/vignettes/starwars.Rmd b/vignettes/starwars.Rmd index 4ab798d..9ac7416 100644 --- a/vignettes/starwars.Rmd +++ b/vignettes/starwars.Rmd @@ -1,8 +1,8 @@ --- -title: "Star Wars films" +title: "Star Wars films (static HTML)" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{Star Wars films} + %\VignetteIndexEntry{Star Wars films (static HTML)} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} ---