From 1b4c7a3a0b02eb48798470fce6b4a8f2fa189512 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Thu, 30 Mar 2023 15:10:10 -0400 Subject: [PATCH 01/14] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f06c7da5a4..e19e7b7006 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 From d65217b521c8b8a9b73809d47df2c3f4ac668ddd Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Thu, 30 Mar 2023 15:10:13 -0400 Subject: [PATCH 02/14] Update NEWS.md --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index a5c1e8316c..13ed9967c2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# gt (development version) +# gt 0.9.0 ## New features From cee6e6a47a35d86718dbcd4ca63e22d6a077ed50 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Thu, 30 Mar 2023 18:43:31 -0400 Subject: [PATCH 03/14] Update utils.R --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 629e20eb58..d0f92ce846 100644 --- a/R/utils.R +++ b/R/utils.R @@ -2175,7 +2175,7 @@ data_get_image_tag <- function(file, dir = "images") { image_url <- file.path(repo_url, dir, file) paste0( - "
", + "
", " Date: Thu, 30 Mar 2023 18:43:52 -0400 Subject: [PATCH 04/14] Update help files using roxygen --- man/countrypops.Rd | 2 +- man/exibble.Rd | 2 +- man/gtcars.Rd | 2 +- man/metro.Rd | 2 +- man/pizzaplace.Rd | 2 +- man/rx_addv.Rd | 2 +- man/rx_adsl.Rd | 2 +- man/sp500.Rd | 2 +- man/sza.Rd | 2 +- man/towny.Rd | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/man/countrypops.Rd b/man/countrypops.Rd index 2faba5c232..ee0e0fccc9 100644 --- a/man/countrypops.Rd +++ b/man/countrypops.Rd @@ -49,7 +49,7 @@ Here is a glimpse at the data available in \code{countrypops}. DATA-1 \if{html}{\out{ -
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/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.
}} } From 31bacf23cfa95ab05834fa7613b56245df758c7f Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 09:22:00 -0400 Subject: [PATCH 05/14] Move juicyjuice back to Imports list --- DESCRIPTION | 2 +- R/export.R | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e19e7b7006..58c4344cfa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,6 +44,7 @@ Imports: glue (>= 1.6.2), htmltools (>= 0.5.4), htmlwidgets (>= 1.6.1), + juicyjuice (>= 0.1.0), magrittr (>= 2.0.2), reactable (>= 0.4.3), rlang (>= 1.0.2), @@ -55,7 +56,6 @@ Imports: Suggests: covr, digest (>= 0.6.31), - juicyjuice (>= 0.1.0), knitr, lubridate, markdown (>= 1.5), 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) From 30e880750985b57fb965d553c56fc5044985c193 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:26:49 -0400 Subject: [PATCH 06/14] Update .Rbuildignore --- .Rbuildignore | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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 From 406dd36a4a1b4cdfb580e2ba2572d99c1c80fc58 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:27:02 -0400 Subject: [PATCH 07/14] Move markdown to Imports --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 58c4344cfa..1bc99ce44f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -46,6 +46,7 @@ Imports: 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), @@ -58,7 +59,6 @@ Suggests: digest (>= 0.6.31), knitr, lubridate, - markdown (>= 1.5), paletteer, RColorBrewer, rmarkdown (>= 2.20), From ff20acc516e11b3137dea07a108a02d0e23f271f Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:27:06 -0400 Subject: [PATCH 08/14] Update NEWS.md --- NEWS.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 13ed9967c2..5fe002895c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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) From b9beda8796d2dd33c0a121a64d3b726a6f9bd788 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:27:20 -0400 Subject: [PATCH 09/14] Update utils.R --- R/utils.R | 47 ++--------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/R/utils.R b/R/utils.R index d0f92ce846..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" From b7025392afb0f557090b41ad085ca629cef0eec6 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:27:25 -0400 Subject: [PATCH 10/14] Update format_data.R --- R/format_data.R | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 From 608d6f0d4b9ccd6023c7af4756a6524815381cd7 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:27:28 -0400 Subject: [PATCH 11/14] Update format_vec.R --- R/format_vec.R | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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") ) { From db00230dc4264539cf117b0b580a692d968f09db Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:27:42 -0400 Subject: [PATCH 12/14] Update fmt_markdown.Rd --- man/fmt_markdown.Rd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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}. From a0ff24e5032da48ec4676d20dcb61dbf806daeb4 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:27:44 -0400 Subject: [PATCH 13/14] Update vec_fmt_markdown.Rd --- man/vec_fmt_markdown.Rd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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"}, From 1b39ed1cb324804d1e7d062a4ef2dbac267ba70b Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 31 Mar 2023 10:32:23 -0400 Subject: [PATCH 14/14] Make ggplot2 a soft dependency --- DESCRIPTION | 2 +- R/image.R | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1bc99ce44f..5d07bb1af9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,7 +40,6 @@ 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), @@ -57,6 +56,7 @@ Imports: Suggests: covr, digest (>= 0.6.31), + ggplot2, knitr, lubridate, paletteer, 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") }