Hao Zhu | 064990d | 2017-10-17 18:08:42 -0400 | [diff] [blame^] | 1 | --- |
| 2 | title: "Untitled" |
| 3 | author: "Hao" |
| 4 | date: "10/15/2017" |
| 5 | output: html_document |
| 6 | --- |
| 7 | |
| 8 | ```{r, include=FALSE} |
| 9 | library(knitr) |
| 10 | library(kableExtra) |
| 11 | library(tidyverse) |
| 12 | ``` |
| 13 | |
| 14 | ```{r} |
| 15 | htmlFun = function(content) { |
| 16 | x = htmltools::tags$div(content, class = 'error') |
| 17 | # you could also do this if you don't care about escaping HTML entities in 'content': |
| 18 | # x = htmltools::HTML(paste('<div class="error">', content, '</div>')) |
| 19 | d = htmltools::htmlDependency( |
| 20 | 'knitr-css', '1.2.3', src = system.file('misc', package = 'knitr'), |
| 21 | stylesheet = 'knitr.css' |
| 22 | ) |
| 23 | x = htmltools::attachDependencies(x, d) |
| 24 | x |
| 25 | } |
| 26 | |
| 27 | htmlFun('Hello World!') |
| 28 | ``` |
| 29 | |
| 30 | ```{r} |
| 31 | mtcars[1:5, 1:2] %>% |
| 32 | mutate(mpg = cell_spec(mpg, tooltip = cyl)) %>% |
| 33 | kable("html", escape = F) %>% |
| 34 | htmltools::HTML() |
| 35 | ``` |