bug fixed: https://stackoverflow.com/questions/44360040/group-rows-function-in-kableextra-package-not-grouping-rows
diff --git a/R/add_indent.R b/R/add_indent.R
index 33ad6f7..3fc2837 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -38,7 +38,7 @@
out <- kable_input
for (i in positions) {
rowtext <- table_info$contents[i + 1]
- out <- sub(rowtext, latex_indent_unit(rowtext), out)
+ out <- sub(rowtext, latex_indent_unit(rowtext), out, perl = TRUE)
}
return(out)
}
diff --git a/R/magic_mirror.R b/R/magic_mirror.R
index 2e415f7..7a274bc 100644
--- a/R/magic_mirror.R
+++ b/R/magic_mirror.R
@@ -70,6 +70,7 @@
)
# Contents
kable_info$contents <- str_match_all(kable_input, "\n(.*)\\\\\\\\")[[1]][,2]
+ kable_info$contents <- sub("\\\\", "\\\\\\\\", kable_info$contents)
if (kable_info$tabular == "longtable" & !is.na(kable_info$caption)) {
kable_info$contents <- kable_info$contents[-1]
}
diff --git a/inst/NEWS b/inst/NEWS
index 6755a6a..c7fdb31 100644
--- a/inst/NEWS
+++ b/inst/NEWS
@@ -5,6 +5,8 @@
* Fixed a bug in grouped header row.
+* Fixed a bug in grouped rows: https://stackoverflow.com/questions/44360040/group-rows-function-in-kableextra-package-not-grouping-rows
+
kableExtra 0.2.1
--------------------------------------------------------------------------------
diff --git a/tests/visual_tests/add_indent_and_group_rows_pdf.Rmd b/tests/visual_tests/add_indent_and_group_rows_pdf.Rmd
index 82e09d2..406c695 100644
--- a/tests/visual_tests/add_indent_and_group_rows_pdf.Rmd
+++ b/tests/visual_tests/add_indent_and_group_rows_pdf.Rmd
@@ -26,3 +26,12 @@
group_rows("Group 2", 8, 10)
```
+```{r}
+dt %>%
+ dplyr::mutate(wt = paste0("%", mpg)) %>%
+kable(format = "latex", booktabs = T) %>%
+ kable_styling() %>%
+ group_rows("Group 1", 4, 7) %>%
+ group_rows("Group 2", 8, 10)
+```
+