Created
February 9, 2023 10:23
-
-
Save hdbt/2c98cf7fb80c630f97e9c8a8286ff988 to your computer and use it in GitHub Desktop.
Workaround for kableExtra HTML View in RNotebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print.kableExtra <- function (x, ...) { | |
view_html <- getOption("kableExtra_view_html", TRUE) | |
if (view_html & interactive()) { | |
dep <- list( | |
rmarkdown::html_dependency_jquery(), | |
rmarkdown::html_dependency_bootstrap(theme = "cosmo"), | |
kableExtra::html_dependency_kePrint(), | |
kableExtra::html_dependency_lightable() | |
) | |
x <- sub('style="', 'style="color: black; ', as.character(x), fixed = TRUE) | |
html_kable <- htmltools::browsable( | |
htmltools::HTML( | |
as.character(x), | |
"<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>" | |
) | |
) | |
htmltools::htmlDependencies(html_kable) <- dep | |
class(html_kable) <- "shiny.tag.list" | |
print(html_kable) | |
} | |
else { | |
cat(as.character(x)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment