Merge pull request #679 from OscardR/master
Support propagation of parameters for `add_header_above` from calls to `header_separate`
diff --git a/R/header_separate.R b/R/header_separate.R
index 7930d28..c01ba97 100644
--- a/R/header_separate.R
+++ b/R/header_separate.R
@@ -11,7 +11,7 @@
#' is a regular expression that matches any sequence of non-alphanumeric values.
#'
#' @export
-header_separate <- function(kable_input, sep = "[^[:alnum:]]+") {
+header_separate <- function(kable_input, sep = "[^[:alnum:]]+", ...) {
kable_format <- attr(kable_input, "format")
if (!kable_format %in% c("html", "latex")) {
warning("Please specify format in kable. kableExtra can customize either ",
@@ -20,14 +20,22 @@
return(kable_input)
}
if (kable_format == "html") {
- return(header_separate_html(kable_input, sep))
+ return(do.call(header_separate_html, list(
+ kable_input = kable_input,
+ sep = sep,
+ ...
+ )))
}
if (kable_format == "latex") {
- return(header_separate_latex(kable_input, sep))
+ return(do.call(header_separate_latex, list(
+ kable_input = kable_input,
+ sep = sep,
+ ...
+ )))
}
}
-header_separate_html <- function(kable_input, sep) {
+header_separate_html <- function(kable_input, sep, ...) {
kable_attrs <- attributes(kable_input)
kable_xml <- kable_as_xml(kable_input)
@@ -66,9 +74,14 @@
if (!"kableExtra" %in% class(out)) class(out) <- c("kableExtra", class(out))
for (l in seq(2, length(header_layers))) {
- out <- kableExtra::add_header_above(
- out, kableExtra::auto_index(header_layers[[l]])
+ out <- do.call(
+ kableExtra::add_header_above,
+ list(
+ kable_input = out,
+ kableExtra::auto_index(header_layers[[l]]),
+ ...
)
+ )
}
return(out)
}
@@ -92,7 +105,7 @@
return(header_layers)
}
-header_separate_latex <- function(kable_input, sep) {
+header_separate_latex <- function(kable_input, sep, ...) {
table_info <- magic_mirror(kable_input)
out <- solve_enc(kable_input)
@@ -124,8 +137,13 @@
attr(out, "kable_meta") <- table_info
for (l in seq(2, length(header_layers))) {
- out <- kableExtra::add_header_above(
- out, kableExtra::auto_index(header_layers[[l]])
+ out <- do.call(
+ kableExtra::add_header_above,
+ list(
+ kable_input = out,
+ kableExtra::auto_index(header_layers[[l]]),
+ ...
+ )
)
}