blob: cf6ba64e158c36b43f3f070ab1a6c02e6bf4c618 [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(
9 htmltools::HTML(as.character(x))
10 )
11 htmlDependencies(html_kable) <- dep
12 class(html_kable) <- "shiny.tag.list"
13 print(html_kable)
Hao Zhueaef4312018-01-10 17:05:23 -050014}
15
Hao Zhu6107f372018-05-21 00:23:26 -040016#' HTML dependency for js script to enable bootstrap tooltip and popup message
17#'
Hao Zhue5b9bff2018-05-20 17:40:03 -040018#' @export
Hao Zhu8a69ad12018-01-10 18:01:41 -050019html_dependency_kePrint <- function() {
20 htmlDependency(name = "kePrint",
21 version = "0.0.1",
Hao Zhu7cb0e372018-01-10 18:29:30 -050022 src = system.file("kePrint-0.0.1",
Hao Zhu8a69ad12018-01-10 18:01:41 -050023 package = "kableExtra"),
24 script = "kePrint.js")
25}
Hao Zhueaef4312018-01-10 17:05:23 -050026
Hao Zhu6107f372018-05-21 00:23:26 -040027#' HTML dependency for Twitter bootstrap (table only)
28#'
Hao Zhueaef4312018-01-10 17:05:23 -050029#' @export
Hao Zhue5b9bff2018-05-20 17:40:03 -040030html_dependency_bsTable <- function() {
31 htmlDependency(name = "bsTable",
32 version = "3.3.7",
33 src = system.file("bootstrapTable-3.3.7",
34 package = "kableExtra"),
35 stylesheet = "bootstrapTable.min.css")
36}
37
38#' @export
Hao Zhuc8306792018-01-11 12:34:35 -050039knit_print.kableExtra <- function(x, ...) {
Hao Zhueaef4312018-01-10 17:05:23 -050040 x <- paste0(x, "\n\n")
Hao Zhuc1450882018-10-03 17:56:26 -040041 kp_dependency <- getOption("kableExtra.knit_print.dependency",
42 default = TRUE)
43 if (kp_dependency) {
44 meta_list <- list(html_dependency_kePrint())
45 bs <- getOption("kableExtra.html.bsTable", default = FALSE)
46 if (bs) {
47 meta_list[[2]] <- html_dependency_bsTable()
48 }
49 } else {
50 meta_list <- NULL
Hao Zhue5b9bff2018-05-20 17:40:03 -040051 }
52 asis_output(x, meta = meta_list)
Hao Zhueaef4312018-01-10 17:05:23 -050053}
54
55
56
57
Hao Zhu9410a272020-08-03 01:11:47 -040058
59