From d83f4061ea2377ded8fcc2a39cab51cf2a7c52e6 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Mon, 18 Apr 2022 16:31:48 +0900 Subject: [PATCH 1/4] apply colformat_md on content rather than dataset --- R/colformat.R | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/R/colformat.R b/R/colformat.R index d96cf1e..3150c27 100644 --- a/R/colformat.R +++ b/R/colformat.R @@ -48,13 +48,15 @@ colformat_md <- function(x, } dataset <- x[[part]]$dataset - col <- names(tidyselect::eval_select(rlang::expr(c(!!.j)), dataset)) + content <- x[[part]][["content"]][["content"]][["data"]] + nm <- colnames(content) + col <- tidyselect::eval_select(rlang::expr(c(!!.j)), dataset[nm]) if (length(col) == 0) { return(x) } - texts <- unlist(dataset[col], use.names = FALSE) + texts <- purrr::map_chr(content[, col], paragraph2txt) # Must evaluate outside add_footnotes due to lazy evaluation of arguments ft <- flextable::compose(x, @@ -80,3 +82,14 @@ colformat_md <- function(x, where <- function(...) { tidyselect::vars_select_helpers$where(...) } + +paragraph2txt <- function(x) { + if (all(is.na(x$txt))) return(NA_character_) + + txt <- x[["txt"]] + img <- x[["img_data"]] + has_img <- !purrr::map_lgl(img, is.null) & !is.na(img) + txt[has_img] <- sprintf("![](%s)", img[has_img]) + + paste(txt[!is.na(txt)], collapse = "") +} From 2520d1020fae30b4d2055f0a3bf8027fefa24594 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Mon, 18 Apr 2022 16:40:49 +0900 Subject: [PATCH 2/4] update NEWS --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index cc73575..ed2ac5c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # ftExtra 0.3.0.9999 * `as_paragraph_md` supports empty string, `""`, as an input (#68). +* `colformat_md` applies on actual content of flextable rather than input dataset (#72). # ftExtra 0.3.0 From 7343400374601155209a0d66a07de3bff9f6f00e Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Mon, 18 Apr 2022 16:45:06 +0900 Subject: [PATCH 3/4] update documents --- docs/404.html | 122 ++-- docs/LICENSE-text.html | 116 +--- docs/LICENSE.html | 135 ++--- docs/articles/format_columns.html | 688 ++++++++++++----------- docs/articles/group-rows.html | 546 +++++++++--------- docs/articles/index.html | 126 +---- docs/articles/transform-headers.html | 269 ++++----- docs/authors.html | 163 ++---- docs/index.html | 155 ++--- docs/news/index.html | 401 ++++++------- docs/pkgdown.css | 83 +-- docs/pkgdown.js | 4 +- docs/pkgdown.yml | 6 +- docs/reference/as_flextable_methods.html | 344 +++++------- docs/reference/as_paragraph_md.html | 242 +++----- docs/reference/colformat_md.html | 260 +++------ docs/reference/footnote_options.html | 200 ++----- docs/reference/index.html | 169 ++---- docs/reference/reexports.html | 136 ++--- docs/reference/separate_header.html | 204 +++---- docs/reference/span_header.html | 194 ++----- docs/reference/with_blanks.html | 174 ++---- docs/sitemap.xml | 63 +++ man/as_flextable_methods.Rd | 1 + 24 files changed, 1931 insertions(+), 2870 deletions(-) create mode 100644 docs/sitemap.xml diff --git a/docs/404.html b/docs/404.html index 8551d5f..2f91119 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1,66 +1,27 @@ - - -
- + + + + -Copyright (c) 2020 Atsushi Yasumoto
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +“Software”), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions:
+The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.