summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-01-01 18:52:24 +0100
committerGeorg Brandl <georg@python.org>2010-01-01 18:52:24 +0100
commit5f549fdaef39969489622757f3822e407bbdc129 (patch)
tree128cb2ba6041b77cc1c7c7ea2657b7aa7a0a8d09
parent6c627c982b24f2c9ba577cc11875b2e624df63d3 (diff)
downloadpygments-5f549fdaef39969489622757f3822e407bbdc129.tar.gz
Fixed lexing of some Ruby quoting peculiarities (#460).
-rw-r--r--CHANGES2
-rw-r--r--pygments/lexers/agile.py12
-rw-r--r--tests/examplefiles/fucked_up.rb (renamed from tests/examplefiles/broken/fucked_up.rb)0
3 files changed, 8 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 0ab55845..1db13bbd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -33,6 +33,8 @@ Version 1.2
- Fixed the CLexer to not highlight ternary statements as labels.
+- Fixed lexing of some Ruby quoting peculiarities (#460).
+
- A few ASM lexer fixes (#450).
- Added new float ops to LLVM.
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index e7d1dc47..40f29c5e 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -560,22 +560,22 @@ class RubyLexer(ExtendedRegexLexer):
# these must come after %<brace>!
states['strings'] += [
# %r regex
- (r'(%r([^a-zA-Z0-9]))([^\2\\]*(?:\\.[^\2\\]*)*)(\2[mixounse]*)',
+ (r'(%r([^a-zA-Z0-9]))((?:\\\2|(?!\2).)*)(\2[mixounse]*)',
intp_regex_callback),
# regular fancy strings with qsw
- (r'%[qsw]([^a-zA-Z0-9])([^\1\\]*(?:\\.[^\1\\]*)*)\1', String.Other),
- (r'(%[QWx]([^a-zA-Z0-9]))([^\2\\]*(?:\\.[^\2\\]*)*)(\2)',
+ (r'%[qsw]([^a-zA-Z0-9])((?:\\\1|(?!\1).)*)\1', String.Other),
+ (r'(%[QWx]([^a-zA-Z0-9]))((?:\\\2|(?!\2).)*)(\2)',
intp_string_callback),
# special forms of fancy strings after operators or
# in method calls with braces
- (r'(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:[^\3\\]*(?:\\.[^\3\\]*)*)\3)',
+ (r'(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)',
bygroups(Text, String.Other, None)),
# and because of fixed width lookbehinds the whole thing a
# second time for line startings...
- (r'^(\s*)(%([\t ])(?:[^\3\\]*(?:\\.[^\3\\]*)*)\3)',
+ (r'^(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)',
bygroups(Text, String.Other, None)),
# all regular fancy strings without qsw
- (r'(%([^a-zA-Z0-9\s]))([^\2\\]*(?:\\.[^\2\\]*)*)(\2)',
+ (r'(%([^a-zA-Z0-9\s]))((?:\\\2|(?!\2).)*)(\2)',
intp_string_callback),
]
diff --git a/tests/examplefiles/broken/fucked_up.rb b/tests/examplefiles/fucked_up.rb
index b1d0ee3b..b1d0ee3b 100644
--- a/tests/examplefiles/broken/fucked_up.rb
+++ b/tests/examplefiles/fucked_up.rb