Helper functions to generate functions to use as slots for the
StyleHtml@funs
classes. These are functions that return
functions.
a function that accepts a character parameter. If applied, each element in the character vector will be wrapped in the div tags
tag_f
and related functions (div_f
, span_f
) produce
functions that are vectorized and will apply opening and closing tags to
each element of a character vector. container_f
on the other hand
produces a function will collapse a character vector into length 1, and only
then applies the tags. Additionally, container_f
already comes with
the “diffobj-container” class specified.
inputs are assumed to be valid class names or CSS styles.
## Assuming class 'ex1' has CSS styles defined elsewhere
tag_f("div", "ex1")(LETTERS[1:5])
#> [1] "<div class='ex1'>A</div>" "<div class='ex1'>B</div>"
#> [3] "<div class='ex1'>C</div>" "<div class='ex1'>D</div>"
#> [5] "<div class='ex1'>E</div>"
## Use convenience function, and add some inline styles
div_f("ex2", c(color="green", `font-family`="arial"))(LETTERS[1:5])
#> [1] "<div class='ex2' style='color: green; font-family: arial;'>A</div>"
#> [2] "<div class='ex2' style='color: green; font-family: arial;'>B</div>"
#> [3] "<div class='ex2' style='color: green; font-family: arial;'>C</div>"
#> [4] "<div class='ex2' style='color: green; font-family: arial;'>D</div>"
#> [5] "<div class='ex2' style='color: green; font-family: arial;'>E</div>"
## Notice how this is a div with pre-specifed class,
## and only one div is created around the entire data
cont_f()(LETTERS[1:5])
#> [1] "<div class='diffobj-container'><pre class='diffobj-content'>ABCDE</pre></div>"