class Rugments::Lexers::Haml

A lexer for the Haml templating system for Ruby. @see haml.info

Public Class Methods

analyze_text(text) click to toggle source
# File lib/rugments/lexers/haml.rb, line 17
def self.analyze_text(text)
  return 0.1 if text.start_with? '!!!'
end
new(opts = {}) click to toggle source

@option opts :filters

A hash of filter name to lexer of how various filters should be
highlighted.  By default, :javascript, :css, :ruby, and :erb
are supported.
Calls superclass method
# File lib/rugments/lexers/haml.rb, line 25
def initialize(opts = {})
  (opts.delete(:filters) || {}).each do |name, lexer|
    unless lexer.respond_to? :lex
      lexer = Lexer.find(lexer) or fail "unknown lexer: #{lexer}"
      lexer = lexer.new(options)
    end

    filters[name.to_s] = lexer
  end

  super(opts)
end

Public Instance Methods

filters() click to toggle source
# File lib/rugments/lexers/haml.rb, line 46
def filters
  @filters ||= {
    'javascript' => Javascript.new(options),
    'css' => CSS.new(options),
    'ruby' => ruby,
    'erb' => ERB.new(options),
    'markdown' => Markdown.new(options),
    # TODO
    # 'sass' => Sass.new(options),
    # 'textile' => Textile.new(options),
    # 'maruku' => Maruku.new(options),
  }
end
html() click to toggle source
# File lib/rugments/lexers/haml.rb, line 42
def html
  @html ||= HTML.new(options)
end
ruby() click to toggle source
# File lib/rugments/lexers/haml.rb, line 38
def ruby
  @ruby ||= Ruby.new(options)
end