lib/rouge/lexers/haml.rb in rouge-2.0.6 vs lib/rouge/lexers/haml.rb in rouge-2.0.7

- old
+ new

@@ -43,10 +43,15 @@ def html @html ||= HTML.new(options) end + def ruby!(state) + ruby.reset! + push state + end + def filters @filters ||= { 'javascript' => Javascript.new(options), 'css' => CSS.new(options), 'ruby' => ruby, @@ -102,11 +107,11 @@ end rule /-/ do token Punctuation reset_stack - push :ruby_line + ruby! :ruby_line end # filters rule /:(#{dot}*)\n/ do |m| token Name::Decorator @@ -129,12 +134,13 @@ rule(/##{identifier}/) { token Name::Function; goto :tag } end state :tag do mixin :css - rule(/\{#{comma_dot}*?\}/) { delegate ruby } + rule(/[{]/) { token Punctuation; ruby! :ruby_tag } rule(/\[#{dot}*?\]/) { delegate ruby } + rule /\(/, Punctuation, :html_attributes rule /\s*\n/, Text, :pop! # whitespace chompers rule /[<>]{1,2}(?=[ \t=])/, Punctuation @@ -151,20 +157,24 @@ state :eval_or_plain do rule /[&!]?==/, Punctuation, :plain rule /[&!]?[=!]/ do token Punctuation reset_stack - push :ruby_line + ruby! :ruby_line end rule(//) { push :plain } end state :ruby_line do rule /\n/, Text, :pop! rule(/,[ \t]*\n/) { delegate ruby } rule /[ ]\|[ \t]*\n/, Str::Escape rule(/.*?(?=(,$| \|)?[ \t]*$)/) { delegate ruby } + end + + state :ruby_tag do + mixin :ruby_inner end state :html_attributes do rule /\s+/, Text rule /#{identifier}\s*=/, Name::Attribute, :html_attribute_value