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

enh(Python) Some Python language improvements #2715

Merged
merged 11 commits into from
Oct 3, 2020

Conversation

klmr
Copy link
Contributor

@klmr klmr commented Sep 29, 2020

(I’m happy to pull these out into separate PRs if that’s more appropriate!)

Details:

Fix keywords and builtins

  • Keywords now correspond exactly to the list in section 2.3.1 of the Python 3.8 reference. Reserved identifiers are not considered.
  • Built-in literal constants now correspond exactly to those listed in the reference 2.
  • Built-in functions correspond to those listed in the reference 3.
  • Built-ins aren’t highlighted directly after a dot; this corresponds to how the IPython REPL highlights e.g. x.len() and (incorrectly) x. len().

Fix string prefixes

  • Remove invalid 'ur' prefix combination
  • Add 'br' prefix combination
  • Make string prefixes case insensitive

* Keywords now correspond exactly to the list in section 2.3.1 of the
  [Python 3.8 reference][1]. Reserved identifiers are not considered.
* Built-in literal constants now correspond exactly to those listed in
  the reference [2].
* Built-in functions correspond to those listed in the reference [3].
* Built-ins aren’t highlighted directly after a dot; this corresponds to
  how the IPython REPL highlights e.g. `x.len()` and (incorrectly)
  `x. len()`.

[1]: https://docs.python.org/3/reference/lexical_analysis.html#keywords
[2]: https://docs.python.org/3/library/constants.html
[3]: https://docs.python.org/3/library/functions.html
* Remove invalid 'ur' prefix combination
* Add 'br' prefix combination
* Make string prefixes case insensitive
@klmr klmr changed the title enh(Py) Some Python language improvements enh(Python) Some Python language improvements Sep 29, 2020
src/languages/python.js Outdated Show resolved Hide resolved
src/languages/python.js Outdated Show resolved Hide resolved
src/languages/python.js Outdated Show resolved Hide resolved
@joshgoebel
Copy link
Member

@klmr Thanks for the effort here!

@joshgoebel joshgoebel added enhancement An enhancement or new feature language labels Sep 30, 2020
@joshgoebel
Copy link
Member

Also, please add a few entries to CHANGES.md.

@joshgoebel
Copy link
Member

@klmr And if you have more time to improve Python I might suggest looking at: #2633 :-)

@klmr
Copy link
Contributor Author

klmr commented Oct 3, 2020

I’m happy to take a look at #2633 but I think that should be a separate PR.

@joshgoebel
Copy link
Member

Of course.

src/languages/python.js Outdated Show resolved Hide resolved
src/languages/python.js Outdated Show resolved Hide resolved
@joshgoebel
Copy link
Member

@klmr Thanks fo much for all the effort on this!

@joshgoebel joshgoebel merged commit 32d1418 into highlightjs:master Oct 3, 2020
@joshgoebel
Copy link
Member

Well, grrr... I didn't mean to truncate all those great notes from the commit, grrrr...

@klmr
Copy link
Contributor Author

klmr commented Oct 3, 2020

Ha, no worries. If somebody’s interested they can refer back to the linked PR for the notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Python) Wrong highlighting of default arguments
2 participants