Add extra_css to spec family
diff --git a/R/column_spec.R b/R/column_spec.R
index 55e01a1..a640a4d 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -23,6 +23,8 @@
#' @param border_right A logical variable indicating whether there should be a
#' border line on the right of the selected column. In HTML, you can also pass
#' in a character string for the CSS of the border line
+#' @param extra_css Extra css text to be passed into the cells of the row. Note
+#' that it's not for the whole column but to each individual cells
#'
#' @examples x <- knitr::kable(head(mtcars), "html")
#' column_spec(x, 1:2, width = "20em", bold = TRUE, italic = TRUE)
@@ -31,7 +33,8 @@
column_spec <- function(kable_input, column,
width = NULL, bold = FALSE, italic = FALSE,
monospace = FALSE, color = NULL, background = NULL,
- border_left = FALSE, border_right = FALSE) {
+ border_left = FALSE, border_right = FALSE,
+ extra_css = NULL) {
if (!is.numeric(column)) {
stop("column must be numeric. ")
}
@@ -44,7 +47,7 @@
return(column_spec_html(kable_input, column, width,
bold, italic, monospace,
color, background,
- border_left, border_right))
+ border_left, border_right, extra_css))
}
if (kable_format == "latex") {
return(column_spec_latex(kable_input, column, width,
@@ -57,7 +60,7 @@
column_spec_html <- function(kable_input, column, width,
bold, italic, monospace,
color, background,
- border_left, border_right) {
+ border_left, border_right, extra_css) {
kable_attrs <- attributes(kable_input)
kable_xml <- read_kable_as_xml(kable_input)
kable_tbody <- xml_tpart(kable_xml, "tbody")
@@ -118,6 +121,10 @@
xml_attr(target_cell, "style") <- paste0(xml_attr(target_cell, "style"),
"border-right:", border_r_css, ";")
}
+ if (!is.null(extra_css)) {
+ xml_attr(target_cell, "style") <- paste0(xml_attr(target_cell, "style"),
+ extra_css)
+ }
}
}