Skip to content

Commit

Permalink
option: tinytable_quarto_figure
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Sep 14, 2024
1 parent dd255b6 commit a53e116
Show file tree
Hide file tree
Showing 7 changed files with 1,619 additions and 18 deletions.
1 change: 1 addition & 0 deletions R/finalize_typst.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ setMethod(
# Quarto cross-references
if (isTRUE(check_dependency("knitr"))) {
quarto_caption <- isTRUE(knitr::pandoc_to("typst")) &&
isFALSE(getOption("tinytable_quarto_figure", default = FALSE))
(!is.null(knitr::opts_current$get()[["label"]]) ||
!is.null(knitr::opts_current$get()[["tbl-cap"]]))
if (quarto_caption) {
Expand Down
10 changes: 8 additions & 2 deletions man-roxygen/global_options.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#'
#' @section Global options:
#'
#' ## Quarto data processing
#' ## Quarto
#'
#' ### Figure environment
#'
#' * `options("tinytable_quarto_figure" = FALSE)`: Typst only. Normally, it is best to allow Quarto to define the figure environment, so the default behavior is to not include one.
#'
#' ### Data Processing
#'
#' The `format_tt(quarto=TRUE)` argument activates Quarto data processing for specific cells. This funcationality comes with a few warnings:
#'
Expand All @@ -22,7 +28,7 @@
#'
#' ## HTML
#'
#' * EXPERIMENTAL `options(tinytable_html_mathjax = TRUE)` inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.
#' * `options(tinytable_html_mathjax = TRUE)` inserts MathJax scripts in the HTML document. Warning: This may conflict with other elements of the page if MathJax is otherwise loaded.
#'
#' ## PDF
#'
Expand Down
13 changes: 11 additions & 2 deletions man/format_tt.Rd

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

13 changes: 11 additions & 2 deletions man/tt.Rd

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

13 changes: 1 addition & 12 deletions sandbox/typst.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,7 @@ keep-typ: true

```{r}
pkgload::load_all()
theme_typst_figure <- function(x, ...) {
fn <- function(table) {
if (isTRUE(table@output == "typst")) {
table@table_string <- paste0("#figure([\n", table@table_string, "\n])")
}
return(table)
}
x <- style_tt(x, finalize = fn)
return(x)
}
options(theme_tt_tinytable = theme_typst_figure)
options(tinytable_quarto_figure = TRUE)
```

```{r}
Expand Down
Loading

0 comments on commit a53e116

Please sign in to comment.