MattDMo / PythonImproved

The best Python language definition for Sublime Text - ever. Includes full support for Unicode, as well as both Python 2 and Python 3 syntax. Check out the Neon Color Scheme for highlighting.
https://packagecontrol.io/packages/Python%20Improved
MIT License
93 stars 11 forks source link

Raw string support #25

Closed RazerM closed 8 years ago

RazerM commented 9 years ago

Raw strings have the same formatting as normal strings, so backslashes are incorrectly interpreted as escapes, for example:

image

It would be useful if raw strings didn't highlight escapes differently.

MattDMo commented 9 years ago

Good point. I'm in the middle of a bunch of changes, so I'll throw this in there too. Thanks!

facelessuser commented 9 years ago

As I recall, raw strings are often used for regex, so the regex highlighter kicks in and that is why escapes are highlighted. As far as I can tell, there is no way to distinguish a raw string that is not meant for regex from a raw string meant for regex. I personally prefer having the escaped chars to no regex highlighting.

MattDMo commented 9 years ago

Another good point. I'll look at exactly how the regexes work - there might be a way to exclude #escaped_chars and still include the escapes defined in source.regex.python. I'm at work now, so I can't look ATM...

FichteFoll commented 9 years ago

By coincidence I found out that this is "fixed" already (as it is in the original Python syntax):

2015-03-08_19 38 32

Basically, upper case R won't apply regex highlighting.

MattDMo commented 8 years ago

As it turns out, while adding an uppercase R will remove regex highlighting, the R is now scoped as a constant instead of storage.type.string.python. I'll see if I can fix this.

MattDMo commented 8 years ago

I'll be releasing 2.1 soon. With it, you can now (again) use R"..." to designate raw strings with no regex highlighting, while r"..." should retain the old behavior.