blob: 279dee711465aed43c4591fe46d9c909a769de60 [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 Zhu8c8ac8b2018-01-23 23:45:13 -050013 print(html_result)
Hao Zhueaef4312018-01-10 17:05:23 -050014}
15
Hao Zhu8a69ad12018-01-10 18:01:41 -050016html_dependency_kePrint <- function() {
17 htmlDependency(name = "kePrint",
18 version = "0.0.1",
Hao Zhu7cb0e372018-01-10 18:29:30 -050019 src = system.file("kePrint-0.0.1",
Hao Zhu8a69ad12018-01-10 18:01:41 -050020 package = "kableExtra"),
21 script = "kePrint.js")
22}
Hao Zhueaef4312018-01-10 17:05:23 -050023
24#' @export
Hao Zhuc8306792018-01-11 12:34:35 -050025knit_print.kableExtra <- function(x, ...) {
Hao Zhueaef4312018-01-10 17:05:23 -050026 x <- paste0(x, "\n\n")
27 asis_output(x)
28}
29
30
31
32