standardize attr pipes
diff --git a/R/add_header_above.R b/R/add_header_above.R
index 90d018a..29ab6d7 100644
--- a/R/add_header_above.R
+++ b/R/add_header_above.R
@@ -35,7 +35,7 @@
# HTML
htmlTable_add_header_above <- function(kable_input, header = NULL) {
if (is.null(header)) return(kable_input)
- table_info <- magic_mirror(kable_input)
+ kable_attrs <- attributes(kable_input)
kable_xml <- read_xml(as.character(kable_input), options = c("COMPACT"))
kable_xml_thead <- xml_tpart(kable_xml, "thead")
@@ -53,7 +53,7 @@
xml_add_child(kable_xml_thead, new_header_row, .where = 0)
out <- structure(as.character(kable_xml), format = "html",
class = "knitr_kable")
- attr(out, "original_kable_meta") <- table_info
+ attributes(out) <- kable_attrs
return(out)
}
diff --git a/R/kable_styling.R b/R/kable_styling.R
index 98e6039..5460bfa 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -100,7 +100,7 @@
position = c("center", "left", "right",
"float_left", "float_right"),
font_size = NULL) {
- table_info <- magic_mirror(kable_input)
+ kable_attrs <- attributes(kable_input)
kable_xml <- read_xml(as.character(kable_input), options = c("COMPACT"))
# Modify class
@@ -158,7 +158,7 @@
out <- structure(as.character(kable_xml), format = "html",
class = "knitr_kable")
- attr(out, "original_kable_meta") <- table_info
+ attributes(out) <- kable_attrs
return(out)
}
diff --git a/R/row_spec.R b/R/row_spec.R
index c19044c..1e12327 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -5,7 +5,8 @@
#' italic text.
#'
#' @param kable_input Output of `knitr::kable()` with `format` specified
-#' @param row A numeric value indicating which row to be selected
+#' @param row A numeric value indicating which row to be selected. You don't
+#' need to count in header rows or group labeling rows.
#' @param bold A T/F value to control whether the text of the selected row
#' need to be bolded.
#' @param italic A T/F value to control whether the text of the selected row
diff --git a/tests/visual_tests/column_row_spec_html.Rmd b/tests/visual_tests/column_row_spec_html.Rmd
index a54ea5f..5ef4f21 100644
--- a/tests/visual_tests/column_row_spec_html.Rmd
+++ b/tests/visual_tests/column_row_spec_html.Rmd
@@ -41,6 +41,17 @@
kable_styling(full_width = F) %>%
column_spec(2, "5cm", bold = T) %>%
column_spec(4, "3cm", italic = T) %>%
- row_spec(1, italic = T)
+ row_spec(1, bold = T)
```
+```{r}
+dt <- mtcars[1:5, 1:6]
+dt$wt <- paste(dt$wt, "%")
+dt$mpg <- paste(dt$mpg, "&")
+dt$cyl <- paste(dt$cyl, "$")
+
+kable(dt, "html") %>%
+ kable_styling(full_width = F) %>%
+ column_spec(7, bold = T) %>%
+ row_spec(5, bold = T, italic = T)
+```
diff --git a/tests/visual_tests/column_row_spec_pdf.Rmd b/tests/visual_tests/column_row_spec_pdf.Rmd
index 07d2ca4..4b9b31e 100644
--- a/tests/visual_tests/column_row_spec_pdf.Rmd
+++ b/tests/visual_tests/column_row_spec_pdf.Rmd
@@ -52,6 +52,7 @@
dt$cyl <- paste(dt$cyl, "$")
kable(dt, "latex", booktabs = T) %>%
+ group_rows("Group 1", 2, 4) %>%
column_spec(7, bold = T) %>%
row_spec(5, bold = T, italic = T)
```