Skip to content

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

Merged
jeanas merged 1 commit intopygments:masterfrom
LaurenceWarne:dont-highlight-unicode-escapes-for-bytes
Aug 14, 2022
Merged

Disable highlighting of Some Escape Codes for Python bytes Literals#2204
jeanas merged 1 commit intopygments:masterfrom
LaurenceWarne:dont-highlight-unicode-escapes-for-bytes

Conversation

@LaurenceWarne
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

3 participants