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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github highlights escape sequences in raw strings. #82

Closed
milesrout opened this issue May 1, 2017 · 8 comments
Closed

Github highlights escape sequences in raw strings. #82

milesrout opened this issue May 1, 2017 · 8 comments

Comments

@milesrout
Copy link

  • Editor name and version: GitHub
  • Platform: GitHub
  • Color scheme: GitHub
  • MagicPython version: GitHub

Github highlights escape sequences in raw strings.

@1st1
Copy link
Member

1st1 commented May 1, 2017

Screenshot?

@milesrout
Copy link
Author

image

@milesrout
Copy link
Author

It should probably be the other way around---highlight in '\n'.join on line 60, don't highlight in r'\node...' on line 62.

@1st1
Copy link
Member

1st1 commented May 1, 2017

Right, this is because lower-case 'r' raw strings are highlighted as regexp literals, for example: https://github.com/python/cpython/blob/master/Lib/http/cookies.py#L432. This isn't a new feature, r'' strings were highlighted as regular expressions in TextMate and Sublime Text (and thus GitHub) from the beginning.

You can use upper-case R prefix to get true raw-string highlighting:

a = R'aaa \n aaa'
a = r'aaa \n aaa'

I'd say it's too late to change this.

@milesrout
Copy link
Author

Oh that's odd. I suppose that's justifiable. What about the lack of highlighting in non-raw strings?

@1st1
Copy link
Member

1st1 commented May 1, 2017

What about the lack of highlighting in non-raw strings?

Well, this is just a convention now in many major editors. Lower-case r'strings' are highlighted as regexps, upper-case R'strings' are highlighted as actual raw strings.

upd: Sorry, misread the question :) @vpetrovykh answered it below.

@vpetrovykh
Copy link
Member

The apparent lack of highlighting of '\n'.join is due to the color scheme choices that GitHub made, not to the lack of distinction in the language package. Basically, you would see the string being highlighted correctly with escaped characters in other editors (like Atom or Sublime Text) with richer color schemes.

@milesrout
Copy link
Author

Hmm, non-ideal but doesn't look like the issue is on your end. Thanks.

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

No branches or pull requests

3 participants