Skip to content
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

Code in un-indented list cannot be parsed #1651

Open
zkamvar opened this issue Aug 28, 2024 · 0 comments
Open

Code in un-indented list cannot be parsed #1651

zkamvar opened this issue Aug 28, 2024 · 0 comments

Comments

@zkamvar
Copy link

zkamvar commented Aug 28, 2024

We ran into an issue in hubverse-org/hubEvals#46 (comment) where we were getting a cryptic error from roxygen2 that said:

failed to evaluate inline markdown code.
Caused by error in `if (...) NULL`:
! missing value where TRUE/FALSE needed

I was able to find the error from

warn_roxy_tag(tag, "failed to evaluate inline markdown code", parent = e)
and and ran trace() to find the bad text and make a reprex:

txt <- r"{text
- a list
with non-indented `r 1+1` text
}"
roxygen2:::markdown_pass1(txt)
#> Error in if (str_sub(line, start - 1 + indent, start + 1 + indent) == : missing value where TRUE/FALSE needed

# Fixing the indent fixes the problem... kinda
txt2 <- gsub("\n", "\n  ", txt)
roxygen2:::markdown_pass1(txt2)
#> [1] "text\n  - a list\n  with non-indented `r 12t\n  "

Created on 2024-08-28 with reprex v2.1.1

The error is coming from the fact that indent could be NA:

roxygen2/R/markdown.R

Lines 111 to 112 in 9652d15

indent <- nchar(str_extract(line, "^[ ]+"))
if (str_sub(line, start - 1 + indent, start + 1 + indent) == "`r ") {

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

No branches or pull requests

1 participant