learnitdown_init: Initialize learnitdown features in an R Markdown document

View source: R/learnitdown_init.R

learnitdown_initR Documentation

Initialize learnitdown features in an R Markdown document

Description

This function must be called in a script run by before_chapter_script entry in ⁠_bookdown.yml⁠ to create required style.css and header.html files.

Usage

learnitdown_init(
  shiny = TRUE,
  h5p = TRUE,
  use.query = FALSE,
  iframe.links = TRUE,
  details.css = TRUE,
  baseurl = "https://example.org",
  institutions = c("institution1", "institution2"),
  courses = c("course1", "course2", "course3"),
  style = "style.css",
  style0 = "style0.css",
  header = "header.html",
  header0 = "header0.html",
  hide.code.msg = "See code"
)

Arguments

shiny

Do we use Shiny applications and do we want to pass parameters and or launch the application on a click?

h5p

Do we use H5P served from a Wordpress site in the same domain as our R Markdown document? The H5P integration plugin, and the H5PxAPIkatchu Wordpress plugins must be installed in order to serve H5P apps and to record the H5P events through the xAPI interface.

use.query

Do we collect user/course/institution data through the URL query string (the part after the question mark in the URL).

iframe.links

If our document is displayed in an iframe, external link should better target their parent window. With this option, external links with no defined target are automatically retargeted when the page loads.

details.css

Do we want to enhance the ⁠<details>⁠ section with a summary surrounded by a light gray box in order to better evidence it.

baseurl

The URL where the site is server from (for H5P integration), it is also the base URL for the associated Wordpress server with H5P plugin. Provide it without the trailing /!

institutions

The list of possible institutions that have specific sections in this document.

courses

The list of courses with specific sections in this document.

style

The path to the 'style.css' file.

style0

The path to a file with additional content to add to the 'style.css' file.

header

The path to the 'header.html' file.

header0

The path to a file with additional content to add to 'header.html'.

hide.code.msg

The message to display for hidden code.

Value

A list with css and html components with the content that was added to respective files is returned invisibly for debugging purposes '(the function is mainly used for its side effect of creating style.css and header.html files for the bookdown format).

Examples

# This is better placed in a setup R chunk or an R inline expression on its
# own line. To see the code injected, use `cat()` at the R prompt:
odir <- setwd(tempdir())
dir.create("temp")
setwd("temp")
# Create fake style0.css and header0.html files to see what happens
cat("\n/* Content from style0.css */\n", file = "style0.css")
cat("\n<!-- Content from header0.html -->\n", file = "header0.html")
# Create style.css and header.html files
(learnitdown_init())
cat(readLines('style.css'), sep = "\n")
cat(readLines('header.html'), sep = "\n")
setwd("..")
unlink("temp")
setwd(odir)
rm(odir)


SciViews/learndown documentation built on Sept. 17, 2024, 8:06 a.m.