Fixed a bug when row_spec and cell_spec used together
diff --git a/R/util.R b/R/util.R
index 528e9bd..e623709 100644
--- a/R/util.R
+++ b/R/util.R
@@ -152,3 +152,17 @@
x <- linebreak(x, align = latex_align, double_escape = TRUE)
}
+clear_color_latex <- function(x, background = F) {
+ term <- if (background) "cellcolor" else "textcolor"
+ regex_1 <- sprintf(
+ "\\\\\\\\%s\\\\\\[HTML\\\\\\]\\\\\\{[a-zA-Z0-9]*\\\\\\}\\\\\\{", term
+ )
+ regex_2 <- sprintf(
+ "\\\\\\\\%s\\\\\\{[a-zA-Z0-9]*\\\\\\}\\\\\\{", term
+ )
+ origin_len <- nchar(x)
+ x <- stringr::str_remove(x, regex_1)
+ x <- stringr::str_remove(x, regex_2)
+ return(ifelse(nchar(x) != origin_len, stringr::str_remove(x, "\\\\\\}$"), x))
+}
+