blob: 09e7cef9d651cc2a0aa41ce352c1b3ee302d3923 [file] [log] [blame]
Hao Zhueaef4312018-01-10 17:05:23 -05001#' @export
Hao Zhub9da01c2018-01-14 21:01:57 -05002print.kableExtra <- function(x, ...) {
Hao Zhuf8207132019-04-20 10:33:12 -04003 dep <- list(
Hao Zhueaef4312018-01-10 17:05:23 -05004 rmarkdown::html_dependency_jquery(),
Hao Zhuf8207132019-04-20 10:33:12 -04005 rmarkdown::html_dependency_bootstrap(theme = "cosmo"),
Hao Zhu8a69ad12018-01-10 18:01:41 -05006 html_dependency_kePrint()
Hao Zhueaef4312018-01-10 17:05:23 -05007 )
Hao Zhuf8207132019-04-20 10:33:12 -04008 html_kable <- htmltools::browsable(
Hao Zhu47b13432020-08-03 16:20:51 -04009 htmltools::HTML(
10 as.character(x),
11 '<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [["$","$"], ["\\(","\\)"]]}})</script>;<script async src="https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>'
12 )
Hao Zhuf8207132019-04-20 10:33:12 -040013 )
14 htmlDependencies(html_kable) <- dep
15 class(html_kable) <- "shiny.tag.list"
16 print(html_kable)
Hao Zhueaef4312018-01-10 17:05:23 -050017}
18
Hao Zhu6107f372018-05-21 00:23:26 -040019#' HTML dependency for js script to enable bootstrap tooltip and popup message
20#'
Hao Zhue5b9bff2018-05-20 17:40:03 -040021#' @export
Hao Zhu8a69ad12018-01-10 18:01:41 -050022html_dependency_kePrint <- function() {
23 htmlDependency(name = "kePrint",
24 version = "0.0.1",
Hao Zhu7cb0e372018-01-10 18:29:30 -050025 src = system.file("kePrint-0.0.1",
Hao Zhu8a69ad12018-01-10 18:01:41 -050026 package = "kableExtra"),
27 script = "kePrint.js")
28}
Hao Zhueaef4312018-01-10 17:05:23 -050029
Hao Zhu6107f372018-05-21 00:23:26 -040030#' HTML dependency for Twitter bootstrap (table only)
31#'
Hao Zhueaef4312018-01-10 17:05:23 -050032#' @export
Hao Zhue5b9bff2018-05-20 17:40:03 -040033html_dependency_bsTable <- function() {
34 htmlDependency(name = "bsTable",
35 version = "3.3.7",
36 src = system.file("bootstrapTable-3.3.7",
37 package = "kableExtra"),
38 stylesheet = "bootstrapTable.min.css")
39}
40
41#' @export
Hao Zhuc8306792018-01-11 12:34:35 -050042knit_print.kableExtra <- function(x, ...) {
Hao Zhueaef4312018-01-10 17:05:23 -050043 x <- paste0(x, "\n\n")
Hao Zhuc1450882018-10-03 17:56:26 -040044 kp_dependency <- getOption("kableExtra.knit_print.dependency",
45 default = TRUE)
46 if (kp_dependency) {
47 meta_list <- list(html_dependency_kePrint())
48 bs <- getOption("kableExtra.html.bsTable", default = FALSE)
49 if (bs) {
50 meta_list[[2]] <- html_dependency_bsTable()
51 }
52 } else {
53 meta_list <- NULL
Hao Zhue5b9bff2018-05-20 17:40:03 -040054 }
55 asis_output(x, meta = meta_list)
Hao Zhueaef4312018-01-10 17:05:23 -050056}
57
58
59
60
Hao Zhu9410a272020-08-03 01:11:47 -040061
62