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)
}