Repository navigation
support exit from nested state in chunk - #14558
Merged
Merged
Conversation
kevinushey
commented
Apr 17, 2024
| { | ||
| // (package) (::) (function) (:) | ||
| token: ["meta.tag", "keyword", "meta.tag", "keyword.operator"], | ||
| regex: /^(\s*[\w\-].*?)(:{2,3})(\s*[\w\-].*?)(:(?:\s+|$))/ |
Collaborator
Author
There was a problem hiding this comment.
I'm fairly certain the use of .* here was a typo; I can't imagine why we'd want to a catch-all regular expression here? That seems too permissive?
gtritchie
approved these changes
Apr 17, 2024
gtritchie
left a comment
Member
There was a problem hiding this comment.
LGTM! Agree we should try to get some automation around this before we touch it again!
kevinushey
added a commit
that referenced
this pull request
Apr 18, 2024
* support exit from nested state in chunk * also permit '.' in dictionary key names
This was referenced May 9, 2024
3 of 4 tasks
4 tasks done
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.
Intent
Addresses #14544.
Addresses #14545.
Approach
For R Markdown documents (and other multi-mode documents), when we embed the highlight rules for a particular language in a chunk, we did so under the assumption that only one single set of language highlight rules could exist in that chunk. This was no longer true with some of the changes we made to support Quarto YAML highlight rules, since we now have:
Markdown => R => YAML
And so if we encountered a chunk end marker while we were in the YAML highlight state, we would only pop a single state, hence placing us back into the R state (rather than the top-level Markdown state).
The fix here is fortunately straightforward: save the state we were in when we entered the chunk, and restore that state when we leave, regardless of how many inner language states were pushed while highlighting the inner chunk.
Automated Tests
N/A, but I intend to take a look at this after fixing the other highlight-related bug.
QA Notes
Test that highlighting in the following document works as expected:
You should see something like:
Documentation
Checklist
NEWS.md