Hao Zhu | eaef431 | 2018-01-10 17:05:23 -0500 | [diff] [blame] | 1 | #' @export |
Hao Zhu | b9da01c | 2018-01-14 21:01:57 -0500 | [diff] [blame] | 2 | print.kableExtra <- function(x, ...) { |
Hao Zhu | f820713 | 2019-04-20 10:33:12 -0400 | [diff] [blame] | 3 | dep <- list( |
Hao Zhu | eaef431 | 2018-01-10 17:05:23 -0500 | [diff] [blame] | 4 | rmarkdown::html_dependency_jquery(), |
Hao Zhu | f820713 | 2019-04-20 10:33:12 -0400 | [diff] [blame] | 5 | rmarkdown::html_dependency_bootstrap(theme = "cosmo"), |
Hao Zhu | 8a69ad1 | 2018-01-10 18:01:41 -0500 | [diff] [blame] | 6 | html_dependency_kePrint() |
Hao Zhu | eaef431 | 2018-01-10 17:05:23 -0500 | [diff] [blame] | 7 | ) |
Hao Zhu | f820713 | 2019-04-20 10:33:12 -0400 | [diff] [blame] | 8 | html_kable <- htmltools::browsable( |
Hao Zhu | 47b1343 | 2020-08-03 16:20:51 -0400 | [diff] [blame^] | 9 | 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 Zhu | f820713 | 2019-04-20 10:33:12 -0400 | [diff] [blame] | 13 | ) |
| 14 | htmlDependencies(html_kable) <- dep |
| 15 | class(html_kable) <- "shiny.tag.list" |
| 16 | print(html_kable) |
Hao Zhu | eaef431 | 2018-01-10 17:05:23 -0500 | [diff] [blame] | 17 | } |
| 18 | |
Hao Zhu | 6107f37 | 2018-05-21 00:23:26 -0400 | [diff] [blame] | 19 | #' HTML dependency for js script to enable bootstrap tooltip and popup message |
| 20 | #' |
Hao Zhu | e5b9bff | 2018-05-20 17:40:03 -0400 | [diff] [blame] | 21 | #' @export |
Hao Zhu | 8a69ad1 | 2018-01-10 18:01:41 -0500 | [diff] [blame] | 22 | html_dependency_kePrint <- function() { |
| 23 | htmlDependency(name = "kePrint", |
| 24 | version = "0.0.1", |
Hao Zhu | 7cb0e37 | 2018-01-10 18:29:30 -0500 | [diff] [blame] | 25 | src = system.file("kePrint-0.0.1", |
Hao Zhu | 8a69ad1 | 2018-01-10 18:01:41 -0500 | [diff] [blame] | 26 | package = "kableExtra"), |
| 27 | script = "kePrint.js") |
| 28 | } |
Hao Zhu | eaef431 | 2018-01-10 17:05:23 -0500 | [diff] [blame] | 29 | |
Hao Zhu | 6107f37 | 2018-05-21 00:23:26 -0400 | [diff] [blame] | 30 | #' HTML dependency for Twitter bootstrap (table only) |
| 31 | #' |
Hao Zhu | eaef431 | 2018-01-10 17:05:23 -0500 | [diff] [blame] | 32 | #' @export |
Hao Zhu | e5b9bff | 2018-05-20 17:40:03 -0400 | [diff] [blame] | 33 | html_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 Zhu | c830679 | 2018-01-11 12:34:35 -0500 | [diff] [blame] | 42 | knit_print.kableExtra <- function(x, ...) { |
Hao Zhu | eaef431 | 2018-01-10 17:05:23 -0500 | [diff] [blame] | 43 | x <- paste0(x, "\n\n") |
Hao Zhu | c145088 | 2018-10-03 17:56:26 -0400 | [diff] [blame] | 44 | 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 Zhu | e5b9bff | 2018-05-20 17:40:03 -0400 | [diff] [blame] | 54 | } |
| 55 | asis_output(x, meta = meta_list) |
Hao Zhu | eaef431 | 2018-01-10 17:05:23 -0500 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
Hao Zhu | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame] | 61 | |
| 62 | |