lib/rouge/lexers/ruby.rb in rouge-1.7.2 vs lib/rouge/lexers/ruby.rb in rouge-1.7.3

- old
+ new

@@ -14,11 +14,11 @@ def self.analyze_text(text) return 1 if text.shebang? 'ruby' end - state :sigil_strings do + state :symbols do # symbols rule %r( : # initial : @{0,2} # optional ivar, for :@foo and :@@foo [a-z_]\w*[!?]? # the symbol @@ -28,11 +28,13 @@ rule %r(:(?:\*\*|[-+]@|[/\%&\|^`~]|\[\]=?|<<|>>|<=?>|<=?|===?)), Str::Symbol rule /:'(\\\\|\\'|[^'])*'/, Str::Symbol rule /:"/, Str::Symbol, :simple_sym + end + state :sigil_strings do # %-sigiled strings # %(abc), %[abc], %<abc>, %.abc., %r.abc., etc delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' } rule /%([rqswQWxiI])?([^\w\s])/ do |m| open = Regexp.escape(m[2]) @@ -73,10 +75,11 @@ end end end state :strings do + mixin :symbols rule /\b[a-z_]\w*?:\s+/, Str::Symbol, :expr_start rule /'(\\\\|\\'|[^'])*'/, Str::Single rule /"/, Str::Double, :simple_string rule /(?<!\.)`/, Str::Backtick, :simple_backtick end @@ -327,11 +330,11 @@ rule /}/, Str::Interpol, :pop! mixin :root end state :string_intp do - rule /\#{/, Str::Interpol, :in_interp + rule /[#][{]/, Str::Interpol, :in_interp rule /#(@@?|\$)[a-z_]\w*/i, Str::Interpol end state :string_intp_escaped do mixin :string_intp @@ -359,9 +362,11 @@ rule %r((/)(?=\S|\s*/)) do token Str::Regex goto :slash_regex end + + mixin :sigil_strings rule(%r((?=\s*/))) { pop! } rule(/\s+/) { token Text; goto :expr_start } rule(//) { pop! }