Repository navigation
Description
System details
RStudio Edition : Desktop
RStudio Version : 2026.07.1
OS Version : Windows 11
R Version : 4.5.2
Steps to reproduce the problem
-
Open a new
.Rmdor.qmdfile in RStudio. -
Switch to Source mode.
-
Insert the following nested fenced divs:
:::::: {#1} something ::::: {#1.1} something ::: {#1.1.1} something ::: ::: {#1.1.2} something ::: ::::: ::::::
Describe the problem in detail
The fenced divs are highlighted with different colors, but the highlighting does not appear to follow the nesting structure.
In particular, after the first nested level is opened, subsequent fences retain the same color until the next closing fence is encountered. (Here, I use “closing fence” to mean the first line containing at least three consecutive colons (::: or more) without attributes or other text.)
As a result, the two nested divs at the same level and the deeper nested div are not visually distinguished according to their nesting depth.
Additional investigation:
While inspecting the source editor in developer mode, I found CSS classes matching:
ace_fenced_div_*ace_fenced_div_text_*
The first fence appears to use ace_fenced_div_0, while the second uses ace_fenced_div_1 etc.
This suggests that these classes may encode the fence color. This mechanism appears to work correctly for unnested divs but seems to break when divs are nested. In the example above, the first four lines containing colons are assigned the class ace_fenced_div_0, although they belong to different nesting levels.
The highlighting appears to assign or maintain the current color index without accounting correctly for nested divs. I am not certain whether this is the root cause; I am including this observation in case it helps with debugging.
Describe the behavior you expected
Nested fenced divs should be highlighted according to their nesting level. Opening and closing fences belonging to the same structural level should use the same color, while different nesting levels should use different colors.
The expected behavior can be seen in Positron:
- I have read the guide for submitting good bug reports.
- I have installed the latest version of RStudio, and confirmed that the issue still persists.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- If I am reporting an RStudio crash, I have included a diagnostics report.
Activity
color fenced divs by nesting depth (#18467)