|
25 | 25 | #' italic = c(FALSE, TRUE), |
26 | 26 | #' bold = c(FALSE, TRUE), |
27 | 27 | #' underlined = c(FALSE, TRUE), |
| 28 | +#' strike = c(FALSE, TRUE), |
28 | 29 | #' color = c("black", "red"), |
29 | 30 | #' shading.color = c("transparent", "yellow"), |
30 | 31 | #' font.family = c("Arial", "Arial"), |
|
42 | 43 | #' italic = c(FALSE, TRUE), |
43 | 44 | #' bold = c(FALSE, TRUE), |
44 | 45 | #' underlined = c(FALSE, TRUE), |
| 46 | +#' strike = c(FALSE, TRUE), |
45 | 47 | #' color = c("black", "red"), |
46 | 48 | #' shading.color = c("transparent", "yellow"), |
47 | 49 | #' font.family = c("Arial", "Arial"), |
@@ -73,6 +75,7 @@ chunk_dataframe <- function(...) { |
73 | 75 | italic = def_lgl, |
74 | 76 | bold = def_lgl, |
75 | 77 | underlined = def_lgl, |
| 78 | + strike = def_lgl, |
76 | 79 | color = def_chr, |
77 | 80 | shading.color = def_chr, |
78 | 81 | font.family = def_chr, |
@@ -103,6 +106,7 @@ default_fptext_prop <- structure( |
103 | 106 | bold = as.logical(NA_integer_), |
104 | 107 | italic = as.logical(NA_integer_), |
105 | 108 | underlined = as.logical(NA_integer_), |
| 109 | + strike = as.logical(NA_integer_), |
106 | 110 | color = NA_character_, |
107 | 111 | shading.color = NA_character_, |
108 | 112 | font.family = NA_character_, |
@@ -182,6 +186,7 @@ as_chunk <- function(x, props = NULL, formatter = format_fun, ...) { |
182 | 186 | italic = sapply(props, function(x) x$italic), |
183 | 187 | bold = sapply(props, function(x) x$bold), |
184 | 188 | underlined = sapply(props, function(x) x$underlined), |
| 189 | + strike = sapply(props, function(x) x$strike), |
185 | 190 | color = sapply(props, function(x) x$color), |
186 | 191 | shading.color = sapply(props, function(x) x$shading.color), |
187 | 192 | font.family = sapply(props, function(x) x$font.family), |
@@ -294,6 +299,38 @@ as_b <- function(x) { |
294 | 299 | x |
295 | 300 | } |
296 | 301 |
|
| 302 | +#' @export |
| 303 | +#' @title Strikethrough chunk |
| 304 | +#' @description The function is producing a chunk with |
| 305 | +#' strikethrough font. |
| 306 | +#' |
| 307 | +#' It is used to add it to the content of a cell of the |
| 308 | +#' flextable with the functions [compose()], [append_chunks()] |
| 309 | +#' or [prepend_chunks()]. |
| 310 | +#' |
| 311 | +#' @inheritParams as_sub |
| 312 | +#' @family chunk elements for paragraph |
| 313 | +#' @examples |
| 314 | +#' ft <- flextable(head(iris), |
| 315 | +#' col_keys = c("Sepal.Length", "dummy") |
| 316 | +#' ) |
| 317 | +#' |
| 318 | +#' ft <- compose(ft, |
| 319 | +#' j = "dummy", |
| 320 | +#' value = as_paragraph( |
| 321 | +#' as_strike(Sepal.Length) |
| 322 | +#' ) |
| 323 | +#' ) |
| 324 | +#' |
| 325 | +#' ft |
| 326 | +as_strike <- function(x) { |
| 327 | + if (!inherits(x, "chunk")) { |
| 328 | + x <- as_chunk(x, formatter = format_fun) |
| 329 | + } |
| 330 | + x$strike <- TRUE |
| 331 | + x |
| 332 | +} |
| 333 | + |
297 | 334 | #' @export |
298 | 335 | #' @title Italic chunk |
299 | 336 | #' @description The function is producing a chunk with |
@@ -541,6 +578,7 @@ as_equation <- function(x, width = 1, height = .2, unit = "in", props = NULL) { |
541 | 578 | italic = sapply(props, function(x) x$italic), |
542 | 579 | bold = sapply(props, function(x) x$bold), |
543 | 580 | underlined = sapply(props, function(x) x$underlined), |
| 581 | + strike = sapply(props, function(x) x$strike), |
544 | 582 | color = sapply(props, function(x) x$color), |
545 | 583 | shading.color = sapply(props, function(x) x$shading.color), |
546 | 584 | font.family = sapply(props, function(x) x$font.family), |
@@ -659,6 +697,7 @@ as_word_field <- function(x, props = NULL, width = .1, height = .15, unit = "in" |
659 | 697 | italic = sapply(props, function(x) x$italic), |
660 | 698 | bold = sapply(props, function(x) x$bold), |
661 | 699 | underlined = sapply(props, function(x) x$underlined), |
| 700 | + strike = sapply(props, function(x) x$strike), |
662 | 701 | color = sapply(props, function(x) x$color), |
663 | 702 | shading.color = sapply(props, function(x) x$shading.color), |
664 | 703 | font.family = sapply(props, function(x) x$font.family), |
|
0 commit comments