21.6 Tags (processing)

Venn Diagram
Venn Diagram of words in R or HTML
Venn Diagram of words in R or HTML
tags <- c("a", "abbr", "address", "article", "aside", "audio",
  "b","bdi", "bdo", "blockquote", "body", "button", "canvas",
  "caption","cite", "code", "colgroup", "data", "datalist",
  "dd", "del","details", "dfn", "div", "dl", "dt", "em",
  "eventsource","fieldset", "figcaption", "figure", "footer",
  "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header",
  "hgroup", "html", "i","iframe", "ins", "kbd", "label",
  "legend", "li", "mark", "map","menu", "meter", "nav",
  "noscript", "object", "ol", "optgroup", "option", "output",
  "p", "pre", "progress", "q", "ruby", "rp","rt", "s", "samp",
  "script", "section", "select", "small", "span", "strong",
  "style", "sub", "summary", "sup", "table", "tbody", "td",
  "textarea", "tfoot", "th", "thead", "time", "title", "tr",
  "u", "ul", "var", "video"
)

void_tags <- c("area", "base", "br", "col", "command", "embed",
  "hr", "img", "input", "keygen", "link", "meta", "param",
  "source", "track", "wbr"
)
html_tags <- c(
  tags |>          #list of tag names from HTML
    set_names() |> #named variable to avoid reserved words!
    map(tag),      #make them function calls
  void_tags |>
    set_names() |>
    map(void_tag)
)

21.6.1 Example

html_tags$ol(
  html_tags$li("What is the ", 
               html_tags$b("derivative"),
               "of $f(x) = 1 + 2cos(3pi x + 4)$?"))
#> <HTML> <ol><li>What is the <b>derivative</b>of $f(x) = 1 + 2cos(3pi x +
#> 4)$?</li></ol>