Skip to content

Commit

Permalink
fix: call fix_border_issues() automatically before printing
Browse files Browse the repository at this point in the history
fix #658
  • Loading branch information
davidgohel committed Oct 10, 2024
1 parent 70da924 commit 31e971c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: flextable
Title: Functions for Tabular Reporting
Version: 0.9.7.013
Version: 0.9.7.014
Authors@R: c(
person("David", "Gohel", , "[email protected]", role = c("aut", "cre")),
person("ArData", role = "cph"),
Expand Down
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# flextable 0.9.7

## Changes

- The `fix_border_issues` function is now useless for users, as it is now
called automatically before printing.

## Issues

- fix caption issue that came with no version of bookdown (issue #645),
Expand All @@ -10,7 +15,9 @@ rmarkdown (issue #632)
- fix right outer border issue in grid format (issue #650)
- fix `flextable_to_rmd()` issue with images in pdf (issue #651)
- fix `flextable_to_rmd()` issue with local chunk `eval` option (issue #631)
- `proc_freq` can now display only the table percentages without the count using `include.table_count = FALSE`.
- `proc_freq` can now display only the table percentages without the count
using `include.table_count = FALSE`.
- bring back support for 'pagedown' with `pagedown >= 0.20.2`

# flextable 0.9.6

Expand Down
1 change: 1 addition & 0 deletions R/body_add_flextable.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ body_add_flextable <- function(x, value,

value <- flextable_global$defaults$post_process_all(value)
value <- flextable_global$defaults$post_process_docx(value)
value <- fix_border_issues(value)

caption_str <- NULL
if (has_caption(value)) {
Expand Down
4 changes: 4 additions & 0 deletions R/border_fix.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#' border that will be seen will be the bottom border of the first cell in the
#' column. From a user point of view, this is wrong, the bottom should be the one
#' defined for cell 3. This function modify the border values to avoid that effect.
#'
#' Note since version `0.9.7` that the function is called automatically
#' before rendering, user should not have to call this function anymore.
#' @param x flextable object
#' @param part partname of the table (one of 'all', 'body', 'header', 'footer')
#' @examples
Expand All @@ -20,6 +23,7 @@
#' print(ft)
#' ft <- fix_border_issues(ft)
#' print(ft)
#' @keywords internal
fix_border_issues <- function(x, part = "all") {
if (!inherits(x, "flextable")) {
stop(sprintf("Function `%s` supports only flextable objects.", "fix_border_issues()"))
Expand Down
4 changes: 4 additions & 0 deletions R/grid_grobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ gen_grob <- function(x,
wrapping = TRUE,
autowidths = TRUE,
just = NULL) {

x <- flextable_global$defaults$post_process_all(x)
x <- fix_border_issues(x)

dots <- list(...)
debug <- isTRUE(dots$debug)
if (identical(fit, TRUE)) fit <- "auto"
Expand Down
1 change: 1 addition & 0 deletions R/ph_with.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ph_with.flextable <- function(x, value, location, ...) {

value <- flextable_global$defaults$post_process_all(value)
value <- flextable_global$defaults$post_process_pptx(value)
value <- fix_border_issues(value)

graphic_frame <- gen_raw_pml(value)
ph_with(x = x, value = as_xml_document(graphic_frame), location = location, ...)
Expand Down
8 changes: 8 additions & 0 deletions R/printers.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ htmltools_value <- function(x, ft.align = NULL, ft.shadow = NULL,
extra_dependencies = NULL) {
x <- flextable_global$defaults$post_process_all(x)
x <- flextable_global$defaults$post_process_html(x)
x <- fix_border_issues(x)

if (!is.null(ft.align)) {
x$properties$align <- ft.align
Expand Down Expand Up @@ -143,6 +144,7 @@ to_html.flextable <- function(x, type = c("table", "img"), ...) {
if ("table" %in% type_output) {
x <- flextable_global$defaults$post_process_all(x)
x <- flextable_global$defaults$post_process_html(x)
x <- fix_border_issues(x)
manual_css <- readLines(system.file(package = "flextable", "web_1.1.3", "tabwid.css"), encoding = "UTF-8")
gen_raw_html(x, class = "tabwid", caption = "", manual_css = paste0(manual_css, collapse = "\n"))
} else {
Expand Down Expand Up @@ -181,6 +183,7 @@ to_html.flextable <- function(x, type = c("table", "img"), ...) {
to_wml.flextable <- function(x, ...) {
x <- flextable_global$defaults$post_process_all(x)
x <- flextable_global$defaults$post_process_docx(x)
x <- fix_border_issues(x)
x <- knitr_update_properties(x)
gen_raw_wml(x)
}
Expand All @@ -198,6 +201,7 @@ to_wml.flextable <- function(x, ...) {
knit_to_html <- function(x, bookdown = FALSE, quarto = FALSE) {
x <- flextable_global$defaults$post_process_all(x)
x <- flextable_global$defaults$post_process_html(x)
x <- fix_border_issues(x)

tab_props <- opts_current_table()
topcaption <- tab_props$topcaption
Expand Down Expand Up @@ -231,6 +235,7 @@ knit_to_html <- function(x, bookdown = FALSE, quarto = FALSE) {
knit_to_wml <- function(x, bookdown = FALSE, quarto = FALSE) {
x <- flextable_global$defaults$post_process_all(x)
x <- flextable_global$defaults$post_process_docx(x)
x <- fix_border_issues(x)

is_rdocx_document <- opts_current$get("is_rdocx_document")
if (is.null(is_rdocx_document)) is_rdocx_document <- FALSE
Expand Down Expand Up @@ -313,6 +318,7 @@ knit_to_latex <- function(x, bookdown, quarto = FALSE) {

x <- flextable_global$defaults$post_process_all(x)
x <- flextable_global$defaults$post_process_pdf(x)
x <- fix_border_issues(x)

if ("none" %in% ft.latex.float) {
lat_container <- latex_container_none()
Expand Down Expand Up @@ -387,6 +393,7 @@ knit_to_pml <- function(x) {
}
x <- flextable_global$defaults$post_process_all(x)
x <- flextable_global$defaults$post_process_pptx(x)
x <- fix_border_issues(x)

uid <- as.integer(runif(n = 1) * 10^9)

Expand Down Expand Up @@ -739,6 +746,7 @@ save_as_html <- function(..., values = NULL, path,
values <- Filter(function(x) inherits(x, "flextable"), values)
values <- lapply(values, flextable_global$defaults$post_process_all)
values <- lapply(values, flextable_global$defaults$post_process_html)
values <- lapply(values, fix_border_issues)
values <- lapply(values, htmltools_value)
titles <- names(values)
show_names <- !is.null(titles)
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ reference:
- border_inner_h
- border_inner_v
- border_outer
- fix_border_issues
- border_remove
- surround
- title: Flextable themes
Expand Down
4 changes: 4 additions & 0 deletions man/fix_border_issues.Rd

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

0 comments on commit 31e971c

Please sign in to comment.