Repository navigation
fix: highlight nested R Markdown chunks through the outer fence - #1947
Merged
eitsupi merged 1 commit intoNov 14, 2026
Merged
Conversation
The scanner now stores the opening fence length and closes the chunk only when a later fence is at least that long. A shorter fence stays inside the outer chunk as content. A fence that meets the length still ends the chunk, and a following chunk is parsed on its own. Added cases cover a longer outer fence around a shorter example, a longer fence before the next chunk, and info strings, bare fences, and unclosed chunks. Fixes REditorSupport#1500
eitsupi
approved these changes
Nov 14, 2026
Contributor
Author
|
Appreciate the merge @eitsupi! Nested R Markdown examples should now stay highlighted through the longer outer fence instead of stopping at the first inner closing fence. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
In an R Markdown document, highlighting of a code chunk stops at the first closing fence, even when that fence only ends a shorter example nested inside a longer chunk. The remainder of the outer chunk is then colored as ordinary text.
The chunk scanner treated every line of three or more backticks as the end of the open chunk. It did not record the length of the opening fence, so a shorter inner fence matched the same end pattern as the outer one.
Summary
The scanner now stores the opening fence length and closes the chunk only when a later fence is at least that long. A shorter fence stays inside the outer chunk as content. A fence that meets the length still ends the chunk, and a following chunk is parsed on its own. Added cases cover a longer outer fence around a shorter example, a longer fence before the next chunk, and info strings, bare fences, and unclosed chunks.
Testing
pnpm run format:checklocally on macOS for the vscode-R isChunkStartLine change; it passed.pnpm run format:checkin a Linux container (localhost/osc-linux-node:22) for the vscode-R isChunkStartLine change; it passed.Closes #1500