Skip to content

Commit

Permalink
Add the whitespace arg to cell_text()
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-iannone committed Jun 11, 2021
1 parent 3c70565 commit c3750da
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
27 changes: 19 additions & 8 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1717,14 +1717,17 @@ currency <- function(...,
#' `"expanded"`, `"extra-expanded"`, or `"ultra-expanded"`. Alternatively, we
#' can supply percentage values from `0\%` to `200\%`, inclusive. Negative
#' percentage values are not allowed.
#' @param decorate Allows for text decoration effect to be applied. Here, we can
#' use `"overline"`, `"line-through"`, or `"underline"`.
#' @param transform Allows for the transformation of text. Options are
#' `"uppercase"`, `"lowercase"`, or `"capitalize"`.
#' @param whitespace A whitespace preservation option. By default, runs of
#' whitespace will be collapsed into single spaces. If we use `"pre"` here,
#' all whitespace will be preserved.
#' @param indent The indentation of the text. Can be provided as a number that
#' is assumed to represent `px` values (or could be wrapped in the [px()])
#' helper function. Alternatively, this can be given as a percentage (easily
#' constructed with [pct()]).
#' @param decorate allows for text decoration effect to be applied. Here, we can
#' use `"overline"`, `"line-through"`, or `"underline"`.
#' @param transform Allows for the transformation of text. Options are
#' `"uppercase"`, `"lowercase"`, or `"capitalize"`.
#'
#' @return A list object of class `cell_styles`.
#'
Expand Down Expand Up @@ -1770,9 +1773,10 @@ cell_text <- function(color = NULL,
style = NULL,
weight = NULL,
stretch = NULL,
indent = NULL,
decorate = NULL,
transform = NULL) {
transform = NULL,
whitespace = NULL,
indent = NULL) {

# Get all assigned values for the functions' arguments
style_names <- formals(cell_text) %>% names()
Expand Down Expand Up @@ -1836,6 +1840,12 @@ cell_text <- function(color = NULL,
in_vector = c("uppercase", "lowercase", "capitalize")
)

validate_style_in(
style_vals, style_names,
arg_name = "whitespace",
in_vector = "pre"
)

cell_style_structure(name = "cell_text", obj = style_vals)
}

Expand All @@ -1852,9 +1862,10 @@ cell_style_to_html.cell_text <- function(style) {
style = "font-style",
weight = "font-weight",
stretch = "font-stretch",
indent = "text-indent",
decorate = "text-decoration",
transform = "text-transform"
transform = "text-transform",
whitespace = "white-space",
indent = "text-indent"
)

html_names <- css_names[names(css)]
Expand Down
21 changes: 13 additions & 8 deletions man/cell_text.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c3750da

Please sign in to comment.