add_class: Add a class to the root node of an HTML string

Description Usage Arguments Value Examples

View source: R/knit.R

Description

Add a class to the root node of an HTML string

Usage

1
add_class(html, class_name)

Arguments

html

Character. An HTML string.

class_name

Character. Class name to be added to the root node.

Value

Character. An HTML string with the class name added to the root node.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(magrittr)

html <- "<!-- function handles comments--><div><p>R is fun</div></p>"
html %>% add_class("second-class")
html %>% add_class(".ok-to-start-with-period")
html %>% add_class("you-can") %>% add_class("chain-function-calls-too")
html %>% add_class("or add five at once")

html <- "<div class='using-single-quotes'><p>R is fun</div></p>"
html %>% add_class("is-ok-too")

html <- "<div class = 'lots-of-spaces'><p>R is fun</div></p>"
html %>% add_class("is-also-ok")

BenjaminWolfe/surprisinglytidy documentation built on Nov. 22, 2019, 11:37 a.m.