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
Constants included from Token::Tokens
Token::Tokens::Num, Token::Tokens::Str
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
append, #delegate, get_state, #get_state, #goto, #group, #groups, #in_state?, #pop!, prepend, #push, #recurse, replace_state, #reset!, #reset_stack, #stack, start, start_procs, #state, state, #state?, state_definitions, 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, title
Methods included from Token::Tokens
Constructor Details
#initialize(opts = {}) ⇒ Haml
Returns a new instance of Haml.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rouge/lexers/haml.rb', line 27 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
19 20 21 |
# File 'lib/rouge/lexers/haml.rb', line 19 def self.analyze_text(text) return 0.1 if text.start_with? '!!!' end |
Instance Method Details
#filters ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rouge/lexers/haml.rb', line 48 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 |