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

fix(python) Fix recognition of numeric literals followed by keywords without whitespace #3367

Merged

Conversation

gibson042
Copy link
Contributor

Fixes #2985

Changes

Allow numeric literals to be followed by a word boundary OR keyword.

Checklist

  • Added markup tests
  • Updated the changelog at CHANGES.md

@gibson042 gibson042 force-pushed the gh-2985-keyword-after-numeric-literal branch from 5091bd6 to 2a2dac1 Compare October 19, 2021 21:24
CHANGES.md Show resolved Hide resolved
// https://docs.python.org/3.9/reference/lexical_analysis.html#whitespace-between-tokens
// We deviate slightly, requiring a word boundary or a keyword
// to avoid accidentally recognizing *prefixes* (e.g., `0` in `0x41` or `08` or `0__1`)
const lookahead = `\\b|${RESERVED_WORDS.join('|')}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well if that isn't rather clever. :)

@joshgoebel joshgoebel merged commit 7028658 into highlightjs:main Oct 22, 2021
@joshgoebel
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(python) Keywords directly following numbers are not detected
2 participants