diff options
-rw-r--r-- | pygments/lexers/agile.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index f235d8cf..0ca1139f 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -509,8 +509,8 @@ class RubyLexer(ExtendedRegexLexer): (r'"', String.Double, 'simple-string'), (r'(?<!\.)`', String.Backtick, 'simple-backtick'), ] - # double-quoted string and symbol + # double-quoted string and symbol for name, ttype, end in ('string', String.Double, '"'), \ ('sym', String.Symbol, '"'), \ ('backtick', String.Backtick, '`'): @@ -522,7 +522,6 @@ class RubyLexer(ExtendedRegexLexer): ] # braced quoted strings - for lbrace, rbrace, name in ('\\{', '\\}', 'cb'), \ ('\\[', '\\]', 'sb'), \ ('\\(', '\\)', 'pa'), \ @@ -560,20 +559,21 @@ class RubyLexer(ExtendedRegexLexer): # these must come after %<brace>! states['strings'] += [ # %r regex - (r'(%r(.))(.*?)(\2[mixounse]*)', intp_regex_callback), - # regular fancy strings - (r'%[qsw](.).*?\1', String.Other), - (r'(%[QWx](.))(.*?)(\2)', intp_string_callback), + (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)', intp_string_callback), # special forms of fancy strings after operators or # in method calls with braces - (r'(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ]).*?\3)', + (r'(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:[^\3\\]*(?:\\.[^\3\\]*)*)\3)', bygroups(Text, String.Other, None)), # and because of fixed with lookbehinds the whole thing a # second time for line startings... - (r'^(\s*)(%([\t ]).*?\3)', + (r'^(\s*)(%([\t ])(?:[^\3\\]*(?:\\.[^\3\\]*)*)\3)', bygroups(Text, String.Other, None)), - # all regular fancy strings - (r'(%([^a-zA-Z0-9\s]))(.*?)(\2)', intp_string_callback), + # all regular fancy strings without qsw + (r'(%([^a-zA-Z0-9\s]))([^\2\\]*(?:\\.[^\2\\]*)*)(\2)', intp_string_callback), ] return states |