diff --git a/.Rbuildignore b/.Rbuildignore index 572b1e03f4..e55a6f952d 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -20,17 +20,20 @@ tests/performance-monitoring tests/testthat/_snaps tests/testthat/test-as_raw_html.R tests/testthat/test-as_word.R +tests/testthat/test-color_handling.R tests/testthat/test-cols_align_decimal.R tests/testthat/test-cols_label.R tests/testthat/test-cols_label_with.R tests/testthat/test-cols_merge.R tests/testthat/test-cols_width_rtf.R +tests/testthat/test-cols_width.R tests/testthat/test-data_color.R +tests/testthat/test-escaping.R tests/testthat/test-extract_cells.R tests/testthat/test-fmt_auto.R tests/testthat/test-fmt_bytes.R tests/testthat/test-fmt_currency.R -tests/testthat/test-fmt_datetime.R +tests/testthat/test-fmt_date_time.R tests/testthat/test-fmt_duration.R tests/testthat/test-fmt_engineering.R tests/testthat/test-fmt_fraction.R @@ -46,23 +49,34 @@ tests/testthat/test-fmt_scientific.R tests/testthat/test-fmt_spelled_num.R tests/testthat/test-footer.R tests/testthat/test-group_column_label.R -tests/testthat/test-gt_multi.R +tests/testthat/test-gt_group.R tests/testthat/test-gtsave.R +tests/testthat/test-h_md_html.R tests/testthat/test-image.R +tests/testthat/test-info_tables.R +tests/testthat/test-input_data_validation.R tests/testthat/test-l_table_parts.R tests/testthat/test-location_cells.R +tests/testthat/test-opt_functions.R +tests/testthat/test-rtf_column_widths.R tests/testthat/test-rtf_page_options.R tests/testthat/test-stub.R tests/testthat/test-substitution.R -tests/testthat/test-summary_rows.R tests/testthat/test-summary_rows_latex.R tests/testthat/test-summary_rows_rtf.R +tests/testthat/test-summary_rows.R tests/testthat/test-tab_footnote.R tests/testthat/test-tab_info.R tests/testthat/test-tab_options.R tests/testthat/test-tab_remove.R -tests/testthat/test-tab_spanner.R tests/testthat/test-tab_spanner_delim.R +tests/testthat/test-tab_spanner.R tests/testthat/test-tab_stub_indent.R +tests/testthat/test-tab_style.R tests/testthat/test-table_parts.R +tests/testthat/test-text_transform.R +tests/testthat/test-util_functions.R +tests/testthat/test-utils_formatters.R +tests/testthat/test-utils_render_html.R +tests/testthat/test-utils.R tests/testthat/test-vec_fmt.R diff --git a/DESCRIPTION b/DESCRIPTION index f06c7da5a4..5d07bb1af9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Type: Package Package: gt -Version: 0.8.0.9000 +Version: 0.9.0 Title: Easily Create Presentation-Ready Display Tables Description: Build display tables from tabular data with an easy-to-use set of functions. With its progressive approach, we can construct display tables @@ -40,11 +40,12 @@ Imports: commonmark (>= 1.8.1), dplyr (>= 1.1.0), fs (>= 1.6.1), - ggplot2 (>= 3.4.1), glue (>= 1.6.2), htmltools (>= 0.5.4), htmlwidgets (>= 1.6.1), + juicyjuice (>= 0.1.0), magrittr (>= 2.0.2), + markdown (>= 1.5), reactable (>= 0.4.3), rlang (>= 1.0.2), sass (>= 0.4.5), @@ -55,10 +56,9 @@ Imports: Suggests: covr, digest (>= 0.6.31), - juicyjuice (>= 0.1.0), + ggplot2, knitr, lubridate, - markdown (>= 1.5), paletteer, RColorBrewer, rmarkdown (>= 2.20), diff --git a/NEWS.md b/NEWS.md index a5c1e8316c..5fe002895c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# gt (development version) +# gt 0.9.0 ## New features @@ -82,8 +82,6 @@ * Fixed some border-related issues for **gt** tables published in R Markdown and Quarto documents (#1120). (#1234) -* The **juicyjuice** package is now a soft dependency. The previous hard requirement presented some problems for users in environments where the installation of the package was difficult (because of its own dependency on **V8**) (#1179). (#1229) - * Added the `quarto.use_bootstrap` and `quarto.disable_processing` options in `tab_options()` to control whether Quarto will add Bootstrap classes to a **gt** table or ignore a **gt** table. (#1222, #1227) * Fixed the unintended appearance of a bottom border in the column spanner row for some CSS environments. (#1209) diff --git a/R/export.R b/R/export.R index fa8adf85c2..5033e278c6 100644 --- a/R/export.R +++ b/R/export.R @@ -497,16 +497,6 @@ as_raw_html <- function( if (inline_css) { - # Check whether juicyjuice is in the package library and stop function - # only if it is not present - if (!requireNamespace("juicyjuice", quietly = TRUE)) { - - cli::cli_abort(c( - "Using `as_raw_html(... , inline_css = TRUE)` requires the `juicyjuice` package.", - "*" = "It can be installed with `install.packages(\"juicyjuice\")`." - )) - } - font_vec <- unique(dt_options_get_value(data = data, option = "table_font_names")) font_family_attr <- as_css_font_family_attr(font_vec = font_vec) diff --git a/R/format_data.R b/R/format_data.R index ddefe2a705..ff15618937 100644 --- a/R/format_data.R +++ b/R/format_data.R @@ -7348,10 +7348,9 @@ fmt_flag <- function( #' #' @inheritParams fmt_number #' @param md_engine The engine preference for Markdown rendering. By default, -#' this is set to `"auto"` where **gt** will choose the **markdown** package -#' if it is available in the user library, otherwise functions from the -#' **commonmark** package will be used. You can explicitly choose one or the -#' other with the `"markdown"` or `"commonmark"` keyword option. +#' this is set to `"markdown"` where **gt** will use the **markdown** package +#' for Markdown conversion to HTML and LaTeX. The other option is +#' `"commonmark"` and with that the **commonmark** package will be used. #' #' @return An object of class `gt_tbl`. #' @@ -7464,7 +7463,7 @@ fmt_markdown <- function( data, columns = everything(), rows = everything(), - md_engine = c("auto", "markdown", "commonmark") + md_engine = c("markdown", "commonmark") ) { # Perform input object validation diff --git a/R/format_vec.R b/R/format_vec.R index 97544de86f..2dd70ac75c 100644 --- a/R/format_vec.R +++ b/R/format_vec.R @@ -3348,10 +3348,9 @@ vec_fmt_duration <- function( #' #' @inheritParams vec_fmt_number #' @param md_engine The engine preference for Markdown rendering. By default, -#' this is set to `"auto"` where **gt** will choose the **markdown** package -#' if it is available in the user library, otherwise functions from the -#' **commonmark** package will be used. You can explicitly choose one or the -#' other with the `"markdown"` or `"commonmark"` keyword option. +#' this is set to `"markdown"` where **gt** will use the **markdown** package +#' for Markdown conversion to HTML and LaTeX. The other option is +#' `"commonmark"` and with that the **commonmark** package will be used. #' #' @return A character vector. #' @@ -3401,7 +3400,7 @@ vec_fmt_duration <- function( #' @export vec_fmt_markdown <- function( x, - md_engine = c("auto", "markdown", "commonmark"), + md_engine = c("markdown", "commonmark"), output = c("auto", "plain", "html", "latex", "rtf", "word") ) { diff --git a/R/image.R b/R/image.R index de5a18489e..3f215d4503 100644 --- a/R/image.R +++ b/R/image.R @@ -298,6 +298,14 @@ ggplot_image <- function( aspect_ratio = 1.0 ) { + if (!requireNamespace("ggplot2", quietly = TRUE)) { + + cli::cli_abort(c( + "Using the `ggplot_image()` function requires the `ggplot2` package.", + "*" = "It can be installed with `install.packages(\"ggplot2\")`." + )) + } + if (is.numeric(height)) { height <- paste0(height, "px") } diff --git a/R/utils.R b/R/utils.R index 629e20eb58..a629916a5e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -405,18 +405,9 @@ get_markdown_engine_fn <- function( context <- match.arg(context) - md_engine_name <- - switch( - md_engine_pref, - auto = , - markdown = "markdown", - commonmark = "commonmark" - ) - md_engine_fn <- switch( md_engine_pref, - auto = , markdown = markdown::mark, commonmark = if (context == "html") { commonmark::markdown_html @@ -425,39 +416,8 @@ get_markdown_engine_fn <- function( } ) - # Stop function if user explicitly chose the `markdown` package as - # the Markdown engine but the package is not available - if (md_engine_pref == "markdown") { - - if (!requireNamespace("markdown", quietly = TRUE)) { - - cli::cli_abort(c( - "Using the \"markdown\"` engine preference requires the `markdown` package.", - "*" = "It can be installed with `install.packages(\"markdown\")`." - )) - } - } - - # If the Markdown engine preference was set to 'auto' (the default) and - # the `markdown` is not available, use the `commonmark` package as a - # fallback; the situation is that `commonmark` is a hard dependency whereas - # `markdown` is a soft dependency (though commonly present in user libraries) - if ( - md_engine_pref == "auto" && - !requireNamespace("markdown", quietly = TRUE) - ) { - - if (context == "html") { - md_engine_fn <- commonmark::markdown_html - } else { - md_engine_fn <- commonmark::markdown_latex - } - - md_engine_name <- "commonmark" - } - md_engine_fn <- c(md_engine_fn) - names(md_engine_fn) <- md_engine_name + names(md_engine_fn) <- md_engine_pref md_engine_fn } @@ -474,10 +434,7 @@ process_text <- function(text, context = "html") { # When processing text globally (outside of the `fmt_markdown()` # function) we will use the 'markdown' package if it is available, # otherwise the 'commonmark' package - if ( - requireNamespace("markdown", quietly = TRUE) && - utils::packageVersion("markdown") >= "1.5" - ) { + if (utils::packageVersion("markdown") >= "1.5") { md_engine <- "markdown" } else { md_engine <- "commonmark" @@ -2175,7 +2132,7 @@ data_get_image_tag <- function(file, dir = "images") { image_url <- file.path(repo_url, dir, file) paste0( - "
", + "
", "This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/exibble.Rd b/man/exibble.Rd index c73b4cba0a..3778640fc5 100644 --- a/man/exibble.Rd +++ b/man/exibble.Rd @@ -59,7 +59,7 @@ Here is the entirety of the \code{exibble} table. DATA-6 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/fmt_markdown.Rd b/man/fmt_markdown.Rd index e93997e89c..8514d25772 100644 --- a/man/fmt_markdown.Rd +++ b/man/fmt_markdown.Rd @@ -8,7 +8,7 @@ fmt_markdown( data, columns = everything(), rows = everything(), - md_engine = c("auto", "markdown", "commonmark") + md_engine = c("markdown", "commonmark") ) } \arguments{ @@ -30,10 +30,9 @@ to filter down to the rows we need (e.g., \verb{[colname_1] > 100 & [colname_2] < 50}).} \item{md_engine}{The engine preference for Markdown rendering. By default, -this is set to \code{"auto"} where \strong{gt} will choose the \strong{markdown} package -if it is available in the user library, otherwise functions from the -\strong{commonmark} package will be used. You can explicitly choose one or the -other with the \code{"markdown"} or \code{"commonmark"} keyword option.} +this is set to \code{"markdown"} where \strong{gt} will use the \strong{markdown} package +for Markdown conversion to HTML and LaTeX. The other option is +\code{"commonmark"} and with that the \strong{commonmark} package will be used.} } \value{ An object of class \code{gt_tbl}. diff --git a/man/gtcars.Rd b/man/gtcars.Rd index f628da60c3..e68ce59d25 100644 --- a/man/gtcars.Rd +++ b/man/gtcars.Rd @@ -78,7 +78,7 @@ Here is a glimpse at the data available in \code{gtcars}. DATA-3 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/metro.Rd b/man/metro.Rd index 136b6bd101..a01e3c4cca 100644 --- a/man/metro.Rd +++ b/man/metro.Rd @@ -86,7 +86,7 @@ Here is a glimpse at the data available in \code{metro}. DATA-8 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/pizzaplace.Rd b/man/pizzaplace.Rd index 15c40de4c2..836e2f6420 100644 --- a/man/pizzaplace.Rd +++ b/man/pizzaplace.Rd @@ -144,7 +144,7 @@ Here is a glimpse at the pizza data available in \code{pizzaplace}. DATA-5 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/rx_addv.Rd b/man/rx_addv.Rd index 56b2b47867..6528aa794c 100644 --- a/man/rx_addv.Rd +++ b/man/rx_addv.Rd @@ -93,7 +93,7 @@ Here is a glimpse at the data available in \code{rx_addv}. DATA-10 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/rx_adsl.Rd b/man/rx_adsl.Rd index 78bc954e0e..892f74f6f8 100644 --- a/man/rx_adsl.Rd +++ b/man/rx_adsl.Rd @@ -84,7 +84,7 @@ Here is a glimpse at the data available in \code{rx_adsl}. DATA-9 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/sp500.Rd b/man/sp500.Rd index 32ae323417..bc13e51189 100644 --- a/man/sp500.Rd +++ b/man/sp500.Rd @@ -46,7 +46,7 @@ Here is a glimpse at the data available in \code{sp500}. DATA-4 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/sza.Rd b/man/sza.Rd index 101c668488..7db4293820 100644 --- a/man/sza.Rd +++ b/man/sza.Rd @@ -64,7 +64,7 @@ Here is a glimpse at the data available in \code{sza}. DATA-2 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/towny.Rd b/man/towny.Rd index c1a0d1190a..7084f907c9 100644 --- a/man/towny.Rd +++ b/man/towny.Rd @@ -99,7 +99,7 @@ Here is a glimpse at the data available in \code{towny}. DATA-7 \if{html}{\out{ -
This image of that of a dataset badge.
+
This image of that of a dataset badge.
}} } diff --git a/man/vec_fmt_markdown.Rd b/man/vec_fmt_markdown.Rd index 869e220343..e4b9990280 100644 --- a/man/vec_fmt_markdown.Rd +++ b/man/vec_fmt_markdown.Rd @@ -6,7 +6,7 @@ \usage{ vec_fmt_markdown( x, - md_engine = c("auto", "markdown", "commonmark"), + md_engine = c("markdown", "commonmark"), output = c("auto", "plain", "html", "latex", "rtf", "word") ) } @@ -14,10 +14,9 @@ vec_fmt_markdown( \item{x}{A numeric vector.} \item{md_engine}{The engine preference for Markdown rendering. By default, -this is set to \code{"auto"} where \strong{gt} will choose the \strong{markdown} package -if it is available in the user library, otherwise functions from the -\strong{commonmark} package will be used. You can explicitly choose one or the -other with the \code{"markdown"} or \code{"commonmark"} keyword option.} +this is set to \code{"markdown"} where \strong{gt} will use the \strong{markdown} package +for Markdown conversion to HTML and LaTeX. The other option is +\code{"commonmark"} and with that the \strong{commonmark} package will be used.} \item{output}{The output style of the resulting character vector. This can either be \code{"auto"} (the default), \code{"plain"}, \code{"html"}, \code{"latex"}, \code{"rtf"},