Skip to content

Fix the length recycling issue with Quarto.#1986

Merged
rich-iannone merged 2 commits intorstudio:masterfrom
olivroy:fmt-md93
Apr 23, 2025
Merged

Fix the length recycling issue with Quarto.#1986
rich-iannone merged 2 commits intorstudio:masterfrom
olivroy:fmt-md93

Conversation

@olivroy
Copy link
Copy Markdown
Collaborator

@olivroy olivroy commented Apr 22, 2025

Summary

Fixes #1985 .

In brief, this

  text[nzchar(text, keepNA = FALSE)] <- non_na_text

didn't return text correctly. It returned non_na_text, (can be of shorter length if ““ is present, hence the warning + bad output:

Warning:
In body[[col]][rows][!is.na(result)] <- omit_na(result) :
  le nombre d'objets à remplacer n'est pas multiple de la taille du remplacement
Calls: <Anonymous> ... <Anonymous> -> render_as_html -> build_data -> render_formats
---
date: "`r Sys.Date()`"
---

```{r}
#| echo: false
#| warning: false
#| message: false

library(gt)
```

```{r}
#| echo: true

# "" (no space) in comment treated as non-existent, so vector is (erroneously) recycled
data <- mtcars[1:5, ]
data$comment <- c("test", "`test`", "", "test", "")
data |> 
  gt()|>
  fmt_markdown(columns = comment)
```

edit: I misread. this fixes #1985
bug introduced in #1855

Copy link
Copy Markdown
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, thanks!!

@rich-iannone rich-iannone merged commit a062cea into rstudio:master Apr 23, 2025
12 checks passed
@olivroy olivroy deleted the fmt-md93 branch June 5, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gt::fmt_markdown renders incorrectly in Quarto document

2 participants