adding some checks to disable the real-time display when RStudio is not running
diff --git a/DESCRIPTION b/DESCRIPTION
index 37ed845..7636ae5 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -38,7 +38,8 @@
viridisLite,
stats,
grDevices,
- htmltools
+ htmltools,
+ rstudioapi
Suggests:
testthat,
magick,
diff --git a/NAMESPACE b/NAMESPACE
index 51150dc..24da701 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -44,6 +44,8 @@
importFrom(rmarkdown,html_dependency_jquery)
importFrom(rmarkdown,latex_dependency)
importFrom(rmarkdown,metadata)
+importFrom(rstudioapi,isAvailable)
+importFrom(rstudioapi,viewer)
importFrom(rvest,html_table)
importFrom(scales,rescale)
importFrom(stats,ave)
diff --git a/R/kableExtra-package.R b/R/kableExtra-package.R
index b0a3fcc..c556076 100644
--- a/R/kableExtra-package.R
+++ b/R/kableExtra-package.R
@@ -71,6 +71,7 @@
#' @importFrom viridisLite viridis
#' @importFrom stats ave
#' @importFrom grDevices col2rgb
+#' @importFrom rstudioapi isAvailable viewer
#' @import htmltools
#' @name kableExtra-package
#' @aliases kableExtra
diff --git a/R/print.R b/R/print.R
index eb006de..13e8568 100644
--- a/R/print.R
+++ b/R/print.R
@@ -7,8 +7,9 @@
)
html_table <- htmltools::HTML(as.character(x))
html_result <- htmltools::tagList(html_header, html_table)
- htmltools::html_print(html_result)
-
+ if (interactive & rstudioapi::isAvailable()) {
+ htmltools::html_print(html_result, viewer = rstudioapi::viewer)
+ }
print(html_result)
}