You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document symbol display in Rmd is not reliable #421
For case 2, if you turn on diagnostics, you will notice a syntax error at line 101-102 as the following:
Although you mark the chunk as eval=FALSE, the code is still parsed. If a syntax error is found, then we can't generate document symbols with it.
In this case, I suggest that you write as the following so that it won't be regarded as an RMarkdown code chunk but a plain R code block in the markdown document and the code in it won't be parsed.
I have just found that Math formula-contained code chunk (e.g., bookdown-style Theorem) also generates errors.
```{theorem, name="Pythagorean theorem"}
For a right triangle, if $c$ denotes the length of the hypotenuse
and $a$ and $b$ denote the lengths of the other two sides, we have
$$a^2 + b^2 = c^2$$
```
@renkun-ken -- Since I don't use {lintr} separately, I am not sure how I could best elaborate this issue in their repo concisely. Would you mind moving this issue there?
Fixed in master by #752, which parses R Markdown/Quarto cells independently rather than treating all extracted code as one expression. Current tests preserve document symbols when another R cell is malformed or has eval: false, and exclude non-R engines from R parsing. This addresses the chunk-detection and whole-document failure discussed here.
Activity
renkun-ken commentedon Apr 24, 2021
For case 2, if you turn on diagnostics, you will notice a syntax error at line 101-102 as the following:
Although you mark the chunk as
eval=FALSE, the code is still parsed. If a syntax error is found, then we can't generate document symbols with it.In this case, I suggest that you write as the following so that it won't be regarded as an RMarkdown code chunk but a plain R code block in the markdown document and the code in it won't be parsed.
jooyoungseo commentedon Apr 24, 2021
Aw, thanks! That makes sense. BTW, my lsp diagnostic has already been turned on like below:
However, it does not give me such the error message as your screenshot.
Would there be any additional settings I need to configure?
jooyoungseo commentedon Apr 24, 2021
renkun-ken commentedon Apr 24, 2021
You may want to update your lintr to latest development version and then you should be able to see the parse error.
jooyoungseo commentedon Apr 24, 2021
Thanks! It works now.
randy3k commentedon Apr 24, 2021
I guess we might want to handle the case that
eval = falseorerror = TRUE.jooyoungseo commentedon Apr 25, 2021
@randy3k, that would be greatly appreciated. I'll re-open this issue.
jooyoungseo commentedon May 8, 2021
I have just found that Math formula-contained code chunk (e.g., bookdown-style Theorem) also generates errors.
Shouldn't it be excluded from errors?
renkun-ken commentedon May 9, 2021
@jooyoungseo Thanks for reporting!
Currently, we use
lintr::lint()to diagnose the whole Rmd document. It handles code chunks internally (https://github.com/jimhester/lintr/blob/master/R/extract.R). If we keep it this way, then we probably need lintr to fix its code chunk detection. Would you like to also raise an issue at https://github.com/jimhester/lintr/issues?renkun-ken commentedon May 9, 2021
Looks like there's a notable gap between how knitr and lintr handles rmarkdown code chunks.
In the above example, knitr renders both but lintr only checks the first chunk.
jooyoungseo commentedon May 10, 2021
@renkun-ken -- Since I don't use {lintr} separately, I am not sure how I could best elaborate this issue in their repo concisely. Would you mind moving this issue there?
renkun-ken commentedon May 10, 2021
I've already raised the linked issue above so there's no need for you to file a new one.
jooyoungseo commentedon May 10, 2021
@renkun-ken, thank you! Hope that it could be addressed on their side soon.
renkun-ken commentedon Oct 6, 2026
Fixed in master by #752, which parses R Markdown/Quarto cells independently rather than treating all extracted code as one expression. Current tests preserve document symbols when another R cell is malformed or has
eval: false, and exclude non-R engines from R parsing. This addresses the chunk-detection and whole-document failure discussed here.Closing as resolved.