Skip to content

Fix empty md("") in Quarto #1772

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

Merged
merged 3 commits into from
Jul 12, 2024
Merged

Fix empty md("") in Quarto #1772

merged 3 commits into from
Jul 12, 2024

Conversation

olivroy
Copy link
Collaborator

@olivroy olivroy commented Jul 11, 2024

Summary

Basically, the underlying problem was that charToRaw("") gives character(0).

I therefore replaced the condition !is.na(x) by nzchar(x, keepNA = FALSE) (a more elegent !is.na(x) & x != "")

I added a mocking mechanism to allow for testing in Quarto functions. I think it is worth adding to it.

For more on mocking, see https://www.tidyverse.org/blog/2023/10/testthat-3-2-0/#mocking.

I could have set a temp env var with withr::local_envvar(), but thought it read more clearly this way.

I tested my test and it indeed fails with current main!

Related GitHub Issues and PRs

Fixes #1769, amends #1690

Checklist

Copy link
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!

@rich-iannone rich-iannone merged commit 7dae195 into rstudio:master Jul 12, 2024
12 checks passed
@olivroy olivroy deleted the md-empty branch July 12, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gt::md() fails when applied to a blank string in new version v0.11.0 on Quarto
2 participants