Put footnotes on the same line with fmt_markdown() in Quarto#1860
Merged
rich-iannone merged 3 commits intorstudio:masterfrom Aug 23, 2024
Merged
Put footnotes on the same line with fmt_markdown() in Quarto#1860rich-iannone merged 3 commits intorstudio:masterfrom
fmt_markdown() in Quarto#1860rich-iannone merged 3 commits intorstudio:masterfrom
Conversation
Collaborator
Author
|
I am using the following script to compare diff #
gt_tbl <- mtcars[1:2, 1:2] |>
gt::gt() |>
gt::cols_label(mpg = gt::md("**MPG**")) |>
gt::tab_footnote(
gt::md("_Adding footnote_"),
locations = gt::cells_column_labels(columns = gt::everything())
)
# inside Quarto
html_code_quarto <- withr::with_envvar(c("QUARTO_BIN_PATH" = "true"), gt:::render_as_html(gt_tbl))
# out of Quarto
html_code <- withr::with_envvar(c("QUARTO_BIN_PATH" = ""), gt:::render_as_html(gt_tbl))
waldo::compare(html_code, html_code_quarto, x_arg = "html", y_arg = "quarto")
html_file <- withr::local_tempfile(lines = html_code, pattern = "html")
quarto_file <- withr::local_tempfile(lines = html_code_quarto, pattern = "quarto")
diffviewer::visual_diff(
html_file,
quarto_file
)The diff seems good! i.e. spans are replaced by their base64 encoding equivalent. The following Qmd doc renders well too ---
title: "Test"
format: html
---
```{r}
#| echo: false
#| message: false
devtools::load_all()
exibble %>%
dplyr::select(num, char, fctr) %>%
dplyr::slice_head(n = 5) %>%
gt() %>%
fmt_markdown(num) %>%
tab_footnote(
md("Problem because num row 1 is fmt_markdown() + also the footnote is wrapped in md."),
locations = cells_body("num", 1)
) %>%
tab_footnote(
"A problem because fctr is labelled with md",
locations = cells_column_labels("fctr")
) %>%
tab_footnote(
"Not a problem",
locations = cells_column_labels("char")
) %>%
cols_label(fctr = md("**Factor**")) %>%
tab_header(md("**Title**")) %>%
tab_spanner(md("**Problem**"), c(2, 3))
``` |
3 tasks
olivroy
commented
Feb 21, 2025
Comment on lines
-48
to
+50
| non_na_text, | ||
| non_na_text_processed, |
Collaborator
Author
There was a problem hiding this comment.
This is the bad / unnecessary change and it is reverted in #1958
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
It seems that using a span instead of div seems to work!!
Sorry about the noise.
I also think it is not necessary to keep the gt_from_md class?#1605 (comment)
Related GitHub Issues and PRs
Fixes #1773
Checklist
testthatunit tests totests/testthatfor any new functionality.