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

Put footnotes on the same line with fmt_markdown() in Quarto #1860

Merged
merged 3 commits into from
Aug 23, 2024

Conversation

olivroy
Copy link
Collaborator

@olivroy olivroy commented Aug 23, 2024

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

@olivroy
Copy link
Collaborator Author

olivroy commented Aug 23, 2024

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
)

image

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))
```

image

Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rich-iannone rich-iannone merged commit 0de5b27 into rstudio:master Aug 23, 2024
12 checks passed
@olivroy olivroy deleted the fix-quarto-rendering branch August 23, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Footnote marker placement when using gt::md() in Quarto in gt v0.11.0
2 participants