blob: 344d43d940bff6b34a16b0e3cda45f121dfef65d [file] [log] [blame]
Hao Zhueaef4312018-01-10 17:05:23 -05001#' @export
Hao Zhub9da01c2018-01-14 21:01:57 -05002print.kableExtra <- function(x, ...) {
Hao Zhueaef4312018-01-10 17:05:23 -05003 html_header <- htmltools::tags$head(
4 rmarkdown::html_dependency_jquery(),
Hao Zhu8a69ad12018-01-10 18:01:41 -05005 rmarkdown::html_dependency_bootstrap(theme = "simplex"),
6 html_dependency_kePrint()
Hao Zhueaef4312018-01-10 17:05:23 -05007 )
Hao Zhueaef4312018-01-10 17:05:23 -05008 html_table <- htmltools::HTML(as.character(x))
Hao Zhu8c8ac8b2018-01-23 23:45:13 -05009 html_result <- htmltools::tagList(html_header, html_table)
Hao Zhu57761542018-03-26 16:32:56 -040010 if (interactive() & rstudioapi::isAvailable()) {
Hao Zhu5b71b2d2018-03-26 16:31:09 -040011 htmltools::html_print(html_result, viewer = rstudioapi::viewer)
12 }
Hao Zhu76762d82018-07-25 20:56:52 -040013 # print(html_result)
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 Zhue5b9bff2018-05-20 17:40:03 -040041 meta_list <- list(html_dependency_kePrint())
42 bs <- getOption("kableExtra.html.bsTable", default = FALSE)
43 if (bs) {
44 meta_list[[2]] <- html_dependency_bsTable()
45 }
46 asis_output(x, meta = meta_list)
Hao Zhueaef4312018-01-10 17:05:23 -050047}
48
49
50
51