From e1f85dd2b682f3e495b9bcc7c01b3a93951a2124 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Mar 2024 19:14:36 +0100 Subject: [PATCH] also allow tinytable --- R/print_html.R | 24 ++++++++++++++++++++++++ R/print_md.R | 10 +++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/R/print_html.R b/R/print_html.R index 9b21d4180..0b10cef6d 100644 --- a/R/print_html.R +++ b/R/print_html.R @@ -150,6 +150,7 @@ print_html.compare_parameters <- function(x, font_size = "100%", line_padding = 4, column_labels = NULL, + engine = "gt", ...) { # check if user supplied digits attributes if (missing(digits)) { @@ -169,6 +170,29 @@ print_html.compare_parameters <- function(x, select <- attributes(x)$output_style } + # markdown engine? + engine <- match.arg(engine, c("gt", "default", "tt")) + + # for tiny table, we can just call print_md() + if (engine == "tt") { + return(print_md( + x, + digits = digits, + ci_digits = ci_digits, + p_digits = p_digits, + caption = caption, + subtitle = subtitle, + footer = footer, + select = select, + split_components = TRUE, + ci_brackets = ci_brackets, + zap_small = zap_small, + groups = groups, + engine = "tt", + outformat = "html" + )) + } + # we need glue-like syntax right now... select <- .convert_to_glue_syntax(style = select, "
") diff --git a/R/print_md.R b/R/print_md.R index 68ae10356..7793d8c9a 100644 --- a/R/print_md.R +++ b/R/print_md.R @@ -173,12 +173,20 @@ print_md.compare_parameters <- function(x, ) if (identical(engine, "tt")) { + # retrieve output format - print_md() may be called from print_html() + dots <- list(...) + if (identical(dots$outformat, "html")) { + outformat <- "html" + } else { + outformat <- "markdown" + } .export_table_tt( x, formatted_table, groups, caption = caption, - footer = footer + footer = footer, + outformat = outformat ) } else { insight::export_table(