Skip to content

Fix the length recycling issue with Quarto. - #1986

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

rich-iannone merged 2 commits into
rstudio:masterfrom
olivroy:fmt-md93

Conversation

@olivroy

@olivroy olivroy commented Apr 22, 2025 •

Copy link
Copy Markdown
Collaborator

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

@rich-iannone rich-iannone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!!

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