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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable highlighting of Some Escape Codes for Python bytes Literals #2204

Merged

Conversation

LaurenceWarne
Copy link
Contributor

@LaurenceWarne LaurenceWarne commented Aug 7, 2022

Hi! I saw escape codes of the form "\N{name}", "\uxxxx" and "\Uxxxxxxxx" are currently highlighted within bytes literals, but according to https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences these escape codes are only recognized in string literals so this PR removes highlighting of these three forms from bytes literals.

I've added a couple of golden tests for escape code highlighting in string and bytes literals, apologies if this is elsewhere I couldn't find anything similar.

Let me know what you think, thanks 馃檪

Disable highlighting of unicode escape codes in python bytes literals,
as described in
https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals.
So escape codes of the form "\N{name}", "\uxxxx" and "\Uxxxxxxxx" will
no longer be highlighted within bytes literals.  Add tests for escape
code highlighting in string and bytes literals.
Copy link
Contributor

@jeanas jeanas left a comment

Choose a reason for hiding this comment

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

LGTM!

@jeanas jeanas merged commit 78efbf0 into pygments:master Aug 14, 2022
@LaurenceWarne
Copy link
Contributor Author

Thanks 馃檪

@Anteru Anteru added this to the 2.13.0 milestone Jan 1, 2023
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.

None yet

3 participants