Skip to content

empty strings marked as md don't get handled by as_word #2119

@thebioengineer

Description

@thebioengineer

Prework

Description

Describe the bug clearly and concisely.

If a label or cell content is marked as md, but is an empty string, the ooxml generated is malformed.

Reproducible example

  • Post a minimal reproducible example so the maintainer can troubleshoot the problems you identify. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.
BOD[1,] |>
  gt::gt() |>
  gt::cols_label(
    Time = gt::md(" ")
  ) |>
  gt::gtsave("test.docx")

Created on 2026-01-26 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> Warning in system2("quarto", "-V", stdout = TRUE, env = paste0("TMPDIR=", :
#> running command '"quarto"
#> TMPDIR=C:/Users/ehh82309/AppData/Local/Temp/RtmpUrQLxb/file281c32b345d5 -V' had
#> status 1
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.1 (2025-06-13 ucrt)
#>  os       Windows 11 x64 (build 26100)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/Los_Angeles
#>  date     2026-01-26
#>  pandoc   3.4 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>  quarto   NA @ C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\quarto.exe
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.6.5   2025-04-23 [1] CRAN (R 4.5.1)
#>  commonmark    2.0.0   2025-07-07 [1] RSPM (R 4.5.0)
#>  digest        0.6.37  2024-08-19 [1] CRAN (R 4.5.1)
#>  dplyr         1.1.4   2023-11-17 [1] CRAN (R 4.5.1)
#>  evaluate      1.0.5   2025-08-27 [1] CRAN (R 4.5.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.5.1)
#>  fs            1.6.6   2025-04-12 [1] CRAN (R 4.5.1)
#>  generics      0.1.4   2025-05-09 [1] CRAN (R 4.5.1)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.5.1)
#>  gt            1.3.0   2026-01-22 [1] CRAN (R 4.5.2)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.5.1)
#>  knitr         1.50    2025-03-16 [1] CRAN (R 4.5.1)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.5.1)
#>  magrittr      2.0.3   2022-03-30 [1] RSPM (R 4.5.0)
#>  pillar        1.11.0  2025-07-04 [1] CRAN (R 4.5.1)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.5.1)
#>  R6            2.6.1   2025-02-15 [1] CRAN (R 4.5.1)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.5.1)
#>  rlang         1.1.6   2025-04-11 [1] CRAN (R 4.5.1)
#>  rmarkdown     2.29    2024-11-04 [1] RSPM (R 4.5.0)
#>  rstudioapi    0.17.1  2024-10-22 [1] CRAN (R 4.5.1)
#>  sessioninfo   1.2.3   2025-02-05 [1] RSPM (R 4.5.0)
#>  tibble        3.3.0   2025-06-08 [1] CRAN (R 4.5.1)
#>  tidyselect    1.2.1   2024-03-11 [1] CRAN (R 4.5.1)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.5.1)
#>  withr         3.0.2   2024-10-28 [1] CRAN (R 4.5.1)
#>  xfun          0.53    2025-08-19 [1] CRAN (R 4.5.1)
#>  xml2          1.4.0   2025-08-20 [1] CRAN (R 4.5.1)
#>  yaml          2.3.10  2024-07-26 [1] CRAN (R 4.5.0)
#> 
#>  [1] C:/Users/ehh82309/AppData/Local/Programs/R/R-4.5.1/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Expected result

What should have happened? Please be as specific as possible.

The cell text for the label is missing from the output ooxml, which makes it malformed when word goes to open it. The issue is that when parse_to_xml() receives the output, which is processed by markdown_to_xml, there was no text made, so no tags processed it.

Session info

End the reproducible example with a call to sessionInfo() in the same session (e.g. reprex(session_info = TRUE)) and include the output.

See reprex

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions