lib/rouge/lexers/slim.rb in rouge-1.8.0 vs lib/rouge/lexers/slim.rb in rouge-1.9.0

- old
+ new

@@ -18,15 +18,10 @@ ruby_chars = /[\w\!\?\@\$]/ # Since you are allowed to wrap lines with a backslash, include \\\n in characters dot = /(\\\n|.)/ - def self.analyze_text(text) - return 1 if text.start_with? 'doctype' - return 1 if text =~ /(\*)(\{.+?\})/ # Contans a hash splat - end - def ruby @ruby ||= Ruby.new(options) end def html @@ -44,10 +39,12 @@ 'scss' => Scss.new(options), 'sass' => Sass.new(options) } end + start { ruby.reset!; html.reset! } + state :root do rule /\s*\n/, Text rule(/\s*/) { |m| token Text; indentation(m[0]) } end @@ -144,10 +141,13 @@ token Punctuation, m[1] #token Keyword::Constant, m[2] delegate ruby, m[2] end + # HTML Entities + rule(/&\S*?;/, Name::Entity) + rule /#{dot}+?/, Text rule /\s*\n/, Text::Whitespace, :pop! end @@ -156,11 +156,11 @@ rule(/#[a-zA-Z][\w:-]*/) { token Name::Function; goto :tag } end state :html_attr do # Strings, double/single quoted - rule %r(\s*(['"])#{dot}*\1), Literal::String, :pop! + rule(/\s*(['"])#{dot}*?\1/, Literal::String, :pop!) # Ruby stuff rule(/(#{ruby_chars}+\(.*?\))/) { |m| delegate ruby, m[1]; pop! } rule(/(#{ruby_chars}+)/) { |m| delegate ruby, m[1]; pop! } @@ -193,9 +193,12 @@ mixin :interpolation rule %r((</?[\w\s\=\'\"]+?/?>)) do |m| # Dirty html delegate html, m[1] end + + # HTML Entities + rule(/&\S*?;/, Name::Entity) #rule /([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/ do rule /#{dot}+?/, Text mixin :indented_block