Class: Rouge::Lexers::Haml
- Inherits:
-
RegexLexer
- Object
- Rouge::Lexer
- RegexLexer
- Rouge::Lexers::Haml
- Includes:
- Indentation
- Defined in:
- lib/rouge/lexers/haml.rb
Overview
A lexer for the Haml templating system for Ruby.
Constant Summary
Constants inherited from RegexLexer
Class Method Summary collapse
Instance Method Summary collapse
- #filters ⇒ Object
- #html ⇒ Object
-
#initialize(opts = {}) ⇒ Haml
constructor
A new instance of Haml.
- #ruby ⇒ Object
Methods included from Indentation
#indentation, #reset!, #starts_block
Methods inherited from RegexLexer
#delegate, get_state, #get_state, #group, #in_state?, #pop!, #push, #reset!, #reset_stack, #run_callback, #run_rule, #stack, start, start_procs, #state, state, #state?, states, #step, #stream_tokens, #token
Methods inherited from Rouge::Lexer
aliases, all, assert_utf8!, #debug, default_options, demo, demo_file, desc, filenames, find, find_fancy, guess, guess_by_filename, guess_by_mimetype, guess_by_source, guesses, lex, #lex, mimetypes, #option, #options, #reset!, #stream_tokens, #tag, tag
Constructor Details
#initialize(opts = {}) ⇒ Haml
Returns a new instance of Haml.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rouge/lexers/haml.rb', line 24 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() end self.filters[name.to_s] = lexer end super(opts) end |
Class Method Details
.analyze_text(text) ⇒ Object
16 17 18 |
# File 'lib/rouge/lexers/haml.rb', line 16 def self.analyze_text(text) return 0.1 if text.start_with? '!!!' end |
Instance Method Details
#filters ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rouge/lexers/haml.rb', line 45 def filters @filters ||= { 'javascript' => Javascript.new(), 'css' => CSS.new(), 'ruby' => ruby, 'erb' => ERB.new(), 'markdown' => Markdown.new(), # TODO # 'sass' => Sass.new(options), # 'textile' => Textile.new(options), # 'maruku' => Maruku.new(options), } end |