diff options
author | LaurenceWarne <17688577+LaurenceWarne@users.noreply.github.com> | 2022-08-14 23:40:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-15 00:40:46 +0200 |
commit | 78efbf0bd992871e560b3997645f5b2fe29d0f3c (patch) | |
tree | 64ec7305856254820d96bb2258dc4ebea0a3964a /tests/snippets/python | |
parent | 581f7ee2567d756c0fbfce5e99ba10d461d08acb (diff) | |
download | pygments-git-78efbf0bd992871e560b3997645f5b2fe29d0f3c.tar.gz |
Disable highlighting of some escape codes for python bytes literals (#2204)
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.
Diffstat (limited to 'tests/snippets/python')
-rw-r--r-- | tests/snippets/python/test_bytes_escape_codes.txt | 24 | ||||
-rw-r--r-- | tests/snippets/python/test_string_escape_codes.txt | 20 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/snippets/python/test_bytes_escape_codes.txt b/tests/snippets/python/test_bytes_escape_codes.txt new file mode 100644 index 00000000..19948d7e --- /dev/null +++ b/tests/snippets/python/test_bytes_escape_codes.txt @@ -0,0 +1,24 @@ +---input--- +b'\\ \n \x12 \777 \u1234 \U00010348 \N{Plus-Minus Sign}' + +---tokens--- +'b' Literal.String.Affix +"'" Literal.String.Single +'\\\\' Literal.String.Escape +' ' Literal.String.Single +'\\n' Literal.String.Escape +' ' Literal.String.Single +'\\x12' Literal.String.Escape +' ' Literal.String.Single +'\\777' Literal.String.Escape +' ' Literal.String.Single +'\\' Literal.String.Single +'u1234 ' Literal.String.Single +'\\' Literal.String.Single +'U00010348 ' Literal.String.Single +'\\' Literal.String.Single +'N' Literal.String.Single +'{' Literal.String.Single +'Plus-Minus Sign}' Literal.String.Single +"'" Literal.String.Single +'\n' Text diff --git a/tests/snippets/python/test_string_escape_codes.txt b/tests/snippets/python/test_string_escape_codes.txt new file mode 100644 index 00000000..5b06329c --- /dev/null +++ b/tests/snippets/python/test_string_escape_codes.txt @@ -0,0 +1,20 @@ +---input--- +'\\ \n \x12 \777 \u1234 \U00010348 \N{Plus-Minus Sign}' + +---tokens--- +"'" Literal.String.Single +'\\\\' Literal.String.Escape +' ' Literal.String.Single +'\\n' Literal.String.Escape +' ' Literal.String.Single +'\\x12' Literal.String.Escape +' ' Literal.String.Single +'\\777' Literal.String.Escape +' ' Literal.String.Single +'\\u1234' Literal.String.Escape +' ' Literal.String.Single +'\\U00010348' Literal.String.Escape +' ' Literal.String.Single +'\\N{Plus-Minus Sign}' Literal.String.Escape +"'" Literal.String.Single +'\n' Text |