added new_tab to cell_spec
diff --git a/R/cell_spec.R b/R/cell_spec.R
index faaf85b..8e3facc 100644
--- a/R/cell_spec.R
+++ b/R/cell_spec.R
@@ -36,6 +36,7 @@
#' bootstrap module manually. Read the package vignette to see how.
#' @param link A vector of strings for url links. Can be used together with
#' tooltip and popover.
+#' @param new_tab T/F for whether to open up the new link in new tab.
#' @param extra_css Extra css text to be passed into the cell
#' @param escape T/F value showing whether special characters should be escaped.
#' @param background_as_tile T/F value indicating if you want to have round
@@ -52,7 +53,7 @@
color = NULL, background = NULL,
align = NULL, font_size = NULL, angle = NULL,
tooltip = NULL, popover = NULL, link = NULL,
- extra_css = NULL,
+ new_tab = FALSE, extra_css = NULL,
escape = TRUE,
background_as_tile = TRUE,
latex_background_in_cell = TRUE) {
@@ -68,7 +69,7 @@
if (tolower(format) == "html") {
return(cell_spec_html(x, bold, italic, monospace, underline, strikeout,
color, background, align, font_size, angle,
- tooltip, popover, link, extra_css,
+ tooltip, popover, link, new_tab, extra_css,
escape, background_as_tile))
}
if (tolower(format) == "latex") {
@@ -80,7 +81,7 @@
cell_spec_html <- function(x, bold, italic, monospace, underline, strikeout,
color, background, align, font_size, angle,
- tooltip, popover, link, extra_css,
+ tooltip, popover, link, new_tab, extra_css,
escape, background_as_tile) {
if (escape) x <- escape_html(x)
cell_style <- NULL
@@ -127,7 +128,12 @@
}
if (!is.null(link)) {
- x <- paste0('<a href="', link, '" style="', cell_style, '" ',
+ if (new_tab) {
+ target_blank = 'target="_blank" '
+ } else {
+ target_blank = NULL
+ }
+ x <- paste0('<a href="', link, '" style="', cell_style, '" ', target_blank,
tooltip_n_popover, '>', x, '</a>')
} else {
x <- paste0('<span style="', cell_style, '" ',
@@ -193,13 +199,13 @@
color = NULL, background = NULL,
align = NULL, font_size = NULL, angle = NULL,
tooltip = NULL, popover = NULL, link = NULL,
- extra_css = NULL,
+ new_tab = FALSE, extra_css = NULL,
escape = TRUE,
background_as_tile = TRUE,
latex_background_in_cell = FALSE) {
cell_spec(x, format, bold, italic, monospace, underline, strikeout,
color, background, align,
- font_size, angle, tooltip, popover, link,
+ font_size, angle, tooltip, popover, link, new_tab,
extra_css, escape, background_as_tile,
latex_background_in_cell)
}
diff --git a/inst/NEWS.md b/inst/NEWS.md
index b7de0c8..45e89a1 100644
--- a/inst/NEWS.md
+++ b/inst/NEWS.md
@@ -32,7 +32,10 @@
viewer. If you want to disable the default behavior, try to set
`options(kableExtra_view_html = F)`. (#455)
+* Added a few alternative HTML table themes. See https://haozhu233.github.io/kableExtra/awesome_table_in_html.html#Alternative_themes
+* Added a `new_tab` option to `cell_spec` to control whether to open up links
+in new tab. (#454)
kableExtra 1.1.0
diff --git a/man/cell_spec.Rd b/man/cell_spec.Rd
index 61ff27c..bf3a057 100644
--- a/man/cell_spec.Rd
+++ b/man/cell_spec.Rd
@@ -21,6 +21,7 @@
tooltip = NULL,
popover = NULL,
link = NULL,
+ new_tab = FALSE,
extra_css = NULL,
escape = TRUE,
background_as_tile = TRUE,
@@ -43,6 +44,7 @@
tooltip = NULL,
popover = NULL,
link = NULL,
+ new_tab = FALSE,
extra_css = NULL,
escape = TRUE,
background_as_tile = TRUE,
@@ -99,6 +101,8 @@
\item{link}{A vector of strings for url links. Can be used together with
tooltip and popover.}
+\item{new_tab}{T/F for whether to open up the new link in new tab.}
+
\item{extra_css}{Extra css text to be passed into the cell}
\item{escape}{T/F value showing whether special characters should be escaped.}
diff --git a/man/kable_classic.Rd b/man/kable_classic.Rd
index b453748..89884ea 100644
--- a/man/kable_classic.Rd
+++ b/man/kable_classic.Rd
@@ -6,18 +6,18 @@
\alias{kable_material}
\title{Alternative HTML themes}
\usage{
-kable_classic(kable_input, striped = FALSE, hover = FALSE, ...)
+kable_classic(kable_input, lightable_options = "basic", ...)
-kable_minimal(kable_input, striped = FALSE, hover = FALSE, ...)
+kable_minimal(kable_input, lightable_options = "basic", ...)
-kable_material(kable_input, striped = FALSE, hover = FALSE, ...)
+kable_material(kable_input, lightable_options = "basic", ...)
}
\arguments{
\item{kable_input}{A HTML kable object.}
-\item{striped}{T/F for adding striped rows.}
-
-\item{hover}{T/F for adding hover effects.}
+\item{lightable_options}{Options to customize lightable. Similar with
+\code{bootstrap_options} in \code{kable_styling}. Choices include \code{basic}, \code{striped}
+and \code{hover}.}
\item{...}{Everything else you need to specify in \code{kable_styling}.}
}