Skip to content

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

Closed

Description

@ddsjoberg

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! 🍁

Activity

  1. changed the title [-]Word output with `gt::md()` in title[/-] [+]Word output with `gt::md()` in column labels[/+] on Sep 24, 2022
  2. rich-iannone commented on Oct 12, 2022

    @rich-iannone
    Member

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

  3. added this to the v0.8.0 milestone on Oct 12, 2022
  4. ddsjoberg commented on Oct 27, 2022

    @ddsjoberg
    ContributorAuthor

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

    image

  5. moved this from Backlog to Next in R Markdown Team Projectson Nov 4, 2022
  6. thebioengineer commented on Nov 4, 2022

    @thebioengineer
    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!

  7. ddsjoberg commented on Nov 4, 2022

    @ddsjoberg
    ContributorAuthor

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

  8. thebioengineer commented on Nov 4, 2022

    @thebioengineer
    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

  9. modified the milestones: v0.8.0, v0.9.0 on Nov 18, 2022
  10. rich-iannone commented on Mar 27, 2023

    @rich-iannone
    Member

    Works great now!

  11. moved this from Next / Ready for Dev to Done in R Markdown Team Projectson Mar 27, 2023
  12. MikeJohnPage commented on Sep 26, 2024

    @MikeJohnPage

    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
  13. rich-iannone commented on Sep 26, 2024

    @rich-iannone
    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).

  14. MikeJohnPage commented on Sep 26, 2024

    @MikeJohnPage

    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

Metadata

Metadata

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions