File: tweak.R

package info (click to toggle)
r-cran-pkgdown 2.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,612 kB
  • sloc: javascript: 458; makefile: 14; sh: 13
file content (14 lines) | stat: -rw-r--r-- 372 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
has_class <- function(html, class) {
  classes <- strsplit(xml2::xml_attr(html, "class"), " ")
  purrr::map_lgl(classes, ~ any(class %in% .x))
}

tweak_class_prepend <- function(x, class) {
  if (length(x) == 0) {
    return(invisible())
  }

  cur <- xml2::xml_attr(x, "class")
  xml2::xml_attr(x, "class") <- ifelse(is.na(cur), class, paste(class, cur))
  invisible()
}