Open cderv opened 2 years ago
Reproducible with older versions of RStudio as well, going back to RStudio Desktop 1.2.5042 on MacOS 12.
I believe supporting this will require a few changes.
First, the chunk highlighter would need to become stateful, and track the number of backticks used in each chunk header / footer. That implementation lives here:
Second, the Ace highlight rules would need to become stateful as well. Those rules are activated here:
And the embedRules()
helper lives here:
The onMatch()
rule would need to both track and check the number of backticks that were matched, and only switch states when the "correct" closing number of backticks is seen.
This problem keeps popping up, including in #10703, #12788, #13384. Let's consolidate it in this issue.
Triage: Consider whether this should be higher than backlog-2, since it keeps coming up.
Also encountering this issue myself. Commenting here to bump and to subscribe to updates. Hope someone posts a resolution soon.
Moving back to triage due to amount of user interest.
I have encountered the same phenomenon with TikZ blocks (not even nested chunks). See the image.
Any fix would be greatly appreciated!
@rje42 What version of RStudio are you using?
@ronblum the lastest one just downloaded: Version 2024.04.2+764. It still occurs!
System details
Steps to reproduce the problem
Open a new rmarkdown document and paste the following content
The content can contain inline code like
r pi * 5^2
, too.Describe the problem in detail
The source editor will not correctly recognized the nested chunk and it will mess up the highlighting
Example with the code chunk not being correctly highlighted, and headers not correctly found after the chunk.
Describe the behavior you expected
This syntax is something rather new in knitr. Last version support nested chunks and some engine will benefit from this like the
comment
engine or theverbatim
engine.WIth the current IDE behavior, it is rather hard to write and read such content.
I would expect the highlighting of the Markdown document in the IDE to be the same as without nested chunk.
cc @yihui