Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bookdown::html_document2 cross-ref #1949

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# gt (development version)

* Fixed an issue where cross-references would fail in bookdown::html_document2 (@olivroy, #1948)

* Significantly faster rendering of certain large tables, by optimizing the internal `rownum_translation()` utility. (@magnusdv, #1924)

* Interactive tables can support selection through the `ihtml.selection_mode` option. (@jonthegeek, #1909)
Expand Down
6 changes: 5 additions & 1 deletion R/knitr-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ kable_caption <- function(label, caption, format) {

create_label <- function(..., latex = FALSE) {
if (isTRUE(knitr::opts_knit$get("bookdown.internal.label"))) {
lab1 <- "(\\#"
if (latex) {
lab1 <- "(\\#"
} else {
lab1 <- "(#"
}
lab2 <- ")"
} else if (latex) {
lab1 <- "\\label{"
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils_render_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_that("bookdown-style crossrefs are added when appropriate", {

# If bookdown, then ref is generated
knitr::opts_knit$set(bookdown.internal.label = TRUE)
expect_caption_eq("test", "(\\#tab:foo)test")
expect_caption_eq("test", "(#tab:foo)test")

expect_null(create_caption_component_h(exibble %>% gt()))

Expand Down
Loading