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

Word output with gt::md() in column labels #1067

Closed
ddsjoberg opened this issue Sep 24, 2022 · 9 comments
Closed

Word output with gt::md() in column labels #1067

ddsjoberg opened this issue Sep 24, 2022 · 9 comments

Comments

@ddsjoberg
Copy link
Contributor

ddsjoberg commented Sep 24, 2022

Description

Using gt::md() with bold syntax in the header does not render properly

Reproducible example

---
title: "gt: checks"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

```{r, message = FALSE}
mtcars[1:5, 1:5] |> 
  gt::gt() |> 
  gt::cols_label(mpg = gt::md("**MPG**"))

image

Expected result

A bolded MPG column label

Session info

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23 ucrt)
#>  os       Windows 10 x64 (build 19042)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/New_York
#>  date     2022-09-24
#>  pandoc   2.18 @ C:/Program Files/RStudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  assertthat    0.2.1      2019-03-21 [2] CRAN (R 4.2.0)
#>  cli           3.4.0      2022-09-08 [2] CRAN (R 4.2.1)
#>  colorspace    2.0-3      2022-02-21 [2] CRAN (R 4.2.0)
#>  commonmark    1.8.0      2022-03-09 [2] CRAN (R 4.2.0)
#>  DBI           1.1.3      2022-06-18 [2] RSPM (R 4.2.0)
#>  digest        0.6.29     2021-12-01 [2] CRAN (R 4.2.0)
#>  dplyr         1.0.10     2022-09-01 [2] CRAN (R 4.2.1)
#>  evaluate      0.16       2022-08-09 [2] RSPM (R 4.2.0)
#>  fansi         1.0.3      2022-03-24 [2] CRAN (R 4.2.0)
#>  fastmap       1.1.0      2021-01-25 [2] CRAN (R 4.2.0)
#>  fs            1.5.2      2021-12-08 [2] CRAN (R 4.2.0)
#>  generics      0.1.3      2022-07-05 [2] RSPM (R 4.2.0)
#>  ggplot2       3.3.6      2022-05-03 [2] CRAN (R 4.2.0)
#>  glue          1.6.2      2022-02-24 [2] CRAN (R 4.2.0)
#>  gt            0.7.0.9000 2022-09-20 [1] local
#>  gtable        0.3.1      2022-09-01 [2] CRAN (R 4.2.1)
#>  highr         0.9        2021-04-16 [2] CRAN (R 4.2.0)
#>  htmltools     0.5.3      2022-07-18 [1] CRAN (R 4.2.1)
#>  knitr         1.40       2022-08-24 [2] CRAN (R 4.2.1)
#>  lifecycle     1.0.2      2022-09-09 [2] CRAN (R 4.2.1)
#>  magrittr      2.0.3      2022-03-30 [2] CRAN (R 4.2.0)
#>  munsell       0.5.0      2018-06-12 [2] CRAN (R 4.2.0)
#>  pillar        1.8.1      2022-08-19 [1] CRAN (R 4.2.1)
#>  pkgconfig     2.0.3      2019-09-22 [2] CRAN (R 4.2.0)
#>  purrr         0.3.4      2020-04-17 [2] CRAN (R 4.2.0)
#>  R.cache       0.16.0     2022-07-21 [2] RSPM (R 4.2.0)
#>  R.methodsS3   1.8.2      2022-06-13 [2] CRAN (R 4.2.0)
#>  R.oo          1.25.0     2022-06-12 [2] CRAN (R 4.2.0)
#>  R.utils       2.12.0     2022-06-28 [2] RSPM (R 4.2.0)
#>  R6            2.5.1      2021-08-19 [2] CRAN (R 4.2.0)
#>  reprex        2.0.2      2022-08-17 [1] RSPM (R 4.2.0)
#>  rlang         1.0.5      2022-08-31 [1] CRAN (R 4.2.1)
#>  rmarkdown     2.16       2022-08-24 [1] CRAN (R 4.2.1)
#>  rstudioapi    0.14       2022-08-22 [2] CRAN (R 4.2.1)
#>  sass          0.4.2      2022-07-16 [1] CRAN (R 4.2.1)
#>  scales        1.2.1      2022-08-20 [2] CRAN (R 4.2.1)
#>  sessioninfo   1.2.2      2021-12-06 [2] CRAN (R 4.2.0)
#>  stringi       1.7.8      2022-07-11 [1] CRAN (R 4.2.1)
#>  stringr       1.4.1      2022-08-20 [2] CRAN (R 4.2.1)
#>  styler        1.7.0      2022-03-13 [2] CRAN (R 4.2.0)
#>  tibble        3.1.8      2022-07-22 [2] RSPM (R 4.2.0)
#>  tidyselect    1.1.2.9000 2022-09-18 [1] Github (r-lib/tidyselect@851ae9c)
#>  utf8          1.2.2      2021-07-24 [2] CRAN (R 4.2.0)
#>  vctrs         0.4.1      2022-04-13 [2] CRAN (R 4.2.0)
#>  withr         2.5.0      2022-03-03 [2] CRAN (R 4.2.0)
#>  xfun          0.33       2022-09-12 [2] CRAN (R 4.2.1)
#>  yaml          2.3.5      2022-02-21 [2] CRAN (R 4.2.0)
#> 
#>  [1] C:/Users/SjobergD/R-dev
#>  [2] C:/Program Files/R/R-4.2.1/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Thank you for the best pkg ever! 🍁

@ddsjoberg ddsjoberg changed the title Word output with gt::md() in title Word output with gt::md() in column labels Sep 24, 2022
@rich-iannone
Copy link
Member

Thanks for discovering this and creating the issue! This one’s pretty important to fix.

@ddsjoberg
Copy link
Contributor Author

Just a bit more detail: this also applies to the spanning headers. Thank you! 🍁

image

@rich-iannone rich-iannone moved this from Backlog to Next in R Markdown Team Projects Nov 4, 2022
@thebioengineer
Copy link
Collaborator

Yeah, right now there isn't much support for markdown inline. I didn't investigate what was existing. It is on the list of things!

@ddsjoberg
Copy link
Contributor Author

ddsjoberg commented Nov 4, 2022

@thebioengineer if i can help in some way, please do let me know! thank you!

@thebioengineer
Copy link
Collaborator

I'm working through it, honestly your examples are super helpful. Testing word is not easy (@rich-iannone and I spent probably too many hours trying to think of ways) other than just opening up the word doc to see if it rendered properly

@rich-iannone rich-iannone modified the milestones: v0.8.0, v0.9.0 Nov 18, 2022
@thebioengineer thebioengineer mentioned this issue Mar 20, 2023
3 tasks
@rich-iannone
Copy link
Member

Works great now!

@github-project-automation github-project-automation bot moved this from Next / Ready for Dev to Done in R Markdown Team Projects Mar 27, 2023
@MikeJohnPage
Copy link

Using gt::md() renders different markdown syntax differently, depending upon where it is called.

Reprex:

---
format:
   docx: default
---


```{r}
gt::gt(gt::sp500[1:10, ]) |>
  gt::tab_header(gt::md("**Test header** <br>*__Test header two__*")) |>
  gt::tab_footnote(gt::md("_Test footnote_ <br>*__Test footnote two__*"))

Note:

  • The header respects the bold and italics, but not the line break
  • The footer does not respect any of the markdown syntax
Screenshot 2024-09-26 at 16 17 06

Versions:

  • gt: 0.11.0.9000
  • quarto: 1.5.57

@rich-iannone
Copy link
Member

@MikeJohnPage Thanks for bringing this up. I've made a new issue, #1892, to track this (comments in old, closed issues tend to get lost in the shuffle).

@MikeJohnPage
Copy link

Thanks @rich-iannone, I appreciate you taking a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants