Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS: Improved contextual keywords #2713

Merged
merged 2 commits into from Jan 29, 2021

Conversation

RunDevelopment
Copy link
Member

This improves how JS handles contextual keywords.

Changes:

  • finally now looks for a { after instead of a } in front.
  • from now looks for the start of a string after (this resolves Javascript syntax rendering error #2712).
  • All contextual keywords will now default to being highlighted if no context is found. This kind of fallback is important because of Prism's matching algorithm. Basically, these contextual keywords use positive lookaheads to assert the context but that context may or may not be part of another token because of matching order and therefore may or may not be inaccessible to the contextual keywords. $ assertions have been added to all lookaheads to implement the fallback.

There might be a few other keywords that would also benefit from context assertions but I haven't seen them causing issues yet, so let's ignore them for now.

@github-actions
Copy link

github-actions bot commented Jan 16, 2021

JS File Size Changes (gzipped)

A total of 1 files have changed, with a combined diff of +8 B (+0.6%).

file master pull size diff % diff
components/prism-javascript.min.js 1.3 KB 1.31 KB +8 B +0.6%

Generated by 🚫 dangerJS against e9c66b2

@RunDevelopment RunDevelopment merged commit 022f90a into PrismJS:master Jan 29, 2021
@RunDevelopment RunDevelopment deleted the js-contextual-keywords branch January 29, 2021 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Javascript syntax rendering error
1 participant