lib/rouge/lexers/haml.rb in rouge-0.2.0 vs lib/rouge/lexers/haml.rb in rouge-0.2.1
- old
+ new
@@ -1,21 +1,26 @@
module Rouge
module Lexers
+ # A lexer for the Haml templating system for Ruby.
+ # @see http://haml.info
class Haml < RegexLexer
+ desc "The Haml templating system for Ruby (haml.info)"
+
tag 'haml'
aliases 'HAML'
filenames '*.haml'
mimetypes 'text/x-haml'
def self.analyze_text(text)
return 0.1 if text.start_with? '!!!'
end
- # option :filters is a hash of filter name to lexer of how
- # various filters should be highlighted. By default, :javascript
- # and :stylesheet are supported.
+ # @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.
def initialize(opts={})
(opts.delete(:filters) || {}).each do |name, lexer|
unless lexer.respond_to? :lex
lexer = Lexer.find(lexer) or raise "unknown lexer: #{lexer}"
lexer = lexer.new(options)
@@ -39,13 +44,13 @@
@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),
- # 'markdown' => Markdown.new(options),
# 'maruku' => Maruku.new(options),
}
end
start { ruby.reset!; html.reset! }