blob: 03e66ab558860956afab2d6bea8bbdd1da7d4587 [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)
14 # if (interactive() & rstudioapi::isAvailable()) {
15 # htmltools::html_print(html_result, viewer = rstudioapi::viewer)
16 # }
17 # print(html_result)
Hao Zhueaef4312018-01-10 17:05:23 -050018}
19
Hao Zhu6107f372018-05-21 00:23:26 -040020#' HTML dependency for js script to enable bootstrap tooltip and popup message
21#'
Hao Zhue5b9bff2018-05-20 17:40:03 -040022#' @export
Hao Zhu8a69ad12018-01-10 18:01:41 -050023html_dependency_kePrint <- function() {
24 htmlDependency(name = "kePrint",
25 version = "0.0.1",
Hao Zhu7cb0e372018-01-10 18:29:30 -050026 src = system.file("kePrint-0.0.1",
Hao Zhu8a69ad12018-01-10 18:01:41 -050027 package = "kableExtra"),
28 script = "kePrint.js")
29}
Hao Zhueaef4312018-01-10 17:05:23 -050030
Hao Zhu6107f372018-05-21 00:23:26 -040031#' HTML dependency for Twitter bootstrap (table only)
32#'
Hao Zhueaef4312018-01-10 17:05:23 -050033#' @export
Hao Zhue5b9bff2018-05-20 17:40:03 -040034html_dependency_bsTable <- function() {
35 htmlDependency(name = "bsTable",
36 version = "3.3.7",
37 src = system.file("bootstrapTable-3.3.7",
38 package = "kableExtra"),
39 stylesheet = "bootstrapTable.min.css")
40}
41
42#' @export
Hao Zhuc8306792018-01-11 12:34:35 -050043knit_print.kableExtra <- function(x, ...) {
Hao Zhueaef4312018-01-10 17:05:23 -050044 x <- paste0(x, "\n\n")
Hao Zhuc1450882018-10-03 17:56:26 -040045 kp_dependency <- getOption("kableExtra.knit_print.dependency",
46 default = TRUE)
47 if (kp_dependency) {
48 meta_list <- list(html_dependency_kePrint())
49 bs <- getOption("kableExtra.html.bsTable", default = FALSE)
50 if (bs) {
51 meta_list[[2]] <- html_dependency_bsTable()
52 }
53 } else {
54 meta_list <- NULL
Hao Zhue5b9bff2018-05-20 17:40:03 -040055 }
56 asis_output(x, meta = meta_list)
Hao Zhueaef4312018-01-10 17:05:23 -050057}
58
59
60
61