Fix #9
diff --git a/R/magic_mirror.R b/R/magic_mirror.R
index 7a274bc..e00032c 100644
--- a/R/magic_mirror.R
+++ b/R/magic_mirror.R
@@ -70,7 +70,7 @@
)
# Contents
kable_info$contents <- str_match_all(kable_input, "\n(.*)\\\\\\\\")[[1]][,2]
- kable_info$contents <- sub("\\\\", "\\\\\\\\", kable_info$contents)
+ kable_info$contents <- latex_contents_escape(kable_info$contents)
if (kable_info$tabular == "longtable" & !is.na(kable_info$caption)) {
kable_info$contents <- kable_info$contents[-1]
}
@@ -86,6 +86,14 @@
return(kable_info)
}
+latex_contents_escape <- function(x) {
+ x <- gsub("\\\\", "\\\\\\\\", x)
+ x <- gsub("\\(", "\\\\(", x)
+ x <- gsub("\\)", "\\\\)", x)
+ x <- gsub("\\[", "\\\\]", x)
+ x <- gsub("\\[", "\\\\]", x)
+}
+
#' Magic Mirror for html table --------
#'
#' @param kable_input The output of kable