diff options
author | Jim Hester <james.f.hester@gmail.com> | 2016-11-22 11:23:14 -0500 |
---|---|---|
committer | Jim Hester <james.f.hester@gmail.com> | 2016-11-22 11:23:14 -0500 |
commit | 1bbff78e786cfee4fb6e2f07ecb415d68e565964 (patch) | |
tree | 9e73a026e759d8623ec450173bdb42608b00470f | |
parent | b246387a02462c8b92f2f9051999bcf92fdb4cd3 (diff) | |
download | pygments-git-1bbff78e786cfee4fb6e2f07ecb415d68e565964.tar.gz |
Support escaping internal backticks
-rw-r--r-- | pygments/lexers/r.py | 2 | ||||
-rw-r--r-- | tests/test_r.py | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/pygments/lexers/r.py b/pygments/lexers/r.py index b03e4798..64cf8bf1 100644 --- a/pygments/lexers/r.py +++ b/pygments/lexers/r.py @@ -80,7 +80,7 @@ class SLexer(RegexLexer): mimetypes = ['text/S-plus', 'text/S', 'text/x-r-source', 'text/x-r', 'text/x-R', 'text/x-r-history', 'text/x-r-profile'] - valid_name = r'`[^`]+`|(?:(?:[a-zA-z]|[_.][^0-9])[\w_.]*)' + valid_name = r'(?:`[^`\\]*(?:\\.[^`\\]*)*`)|(?:(?:[a-zA-z]|[_.][^0-9])[\w_.]*)' tokens = { 'comments': [ (r'#.*$', Comment.Single), diff --git a/tests/test_r.py b/tests/test_r.py index a6464480..d0e9090b 100644 --- a/tests/test_r.py +++ b/tests/test_r.py @@ -48,6 +48,15 @@ class RTest(unittest.TestCase): ] self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + def testName3(self): + # Internal backticks can be escaped + fragment = u'`.1 \` blah`' + tokens = [ + (Name, u'`.1 \` blah`'), + (Token.Text, u'\n'), + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + def testCustomOperator(self): fragment = u'7 % and % 8' tokens = [ |