Skip to content

Raw string support #25

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

Closed
RazerM opened this issue Feb 3, 2015 · 6 comments
Closed

Raw string support #25

RazerM opened this issue Feb 3, 2015 · 6 comments

Comments

@RazerM
Copy link

RazerM commented Feb 3, 2015

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
Copy link
Owner

MattDMo commented Feb 3, 2015

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

@MattDMo MattDMo self-assigned this Feb 3, 2015
@MattDMo MattDMo added the bug label Feb 3, 2015
@facelessuser
Copy link
Contributor

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
Copy link
Owner

MattDMo commented Feb 3, 2015

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
Copy link

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
Copy link
Owner

MattDMo commented Dec 4, 2015

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 pushed a commit that referenced this issue Dec 4, 2015
* can now differentiate between raw-regex strings (r"...") and raw strings (R"..."). raw-regex will include regex syntax highlighting, raw-only will not. Addresses #25
* fixed `constant.other.allcaps` to not highlight capital letters just before `.`, `(`, `'`, or `"`.
* magic function definitions are now properly highlighted again. Fixes #51
    (small problem - both names and calls are scoped as name...)
@MattDMo
Copy link
Owner

MattDMo commented Dec 4, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants