Fix: TOML table to avoid splitting brackets from key#4045
Open
alasdairwilson wants to merge 1 commit intoPrismJS:v2from
Open
Fix: TOML table to avoid splitting brackets from key#4045alasdairwilson wants to merge 1 commit intoPrismJS:v2from
alasdairwilson wants to merge 1 commit intoPrismJS:v2from
Conversation
✅ Deploy Preview for dev-prismjs-com ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
e385583 to
ae5d09d
Compare
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.
I had discovered an issue where TOML table header parsing had undesired behaviour where table declarations like [table] and [[array]] were being split across multiple tokens, creating split spans when parsed. The bug was actually, for me, found in refractor but it is prismjs language files that have the issue.
I have implemented a change in behaviour to toml header parsing in this PR which keeps the entire table header as a single token, you can see the change in the diff on the test output but basically [header] becomes [header] rather than "[", "header" ,"]" (and also made a simplification by removing insertkey in place of dottedkeyHowever, having thought about it a bit longer, I do recognise this is perhaps not an upgrade since no longer does this allow separate styling of the punctuation in the header compared to the key.So what I would propose is to copy the approach used in parsing ini files, where the whole thing becomes a nested structure
using this:
to produce this output:
I swapped to this approach that mirrors ini as, on reflection, it is clearly the best choice.