Class: REHTML::Tokenizer

Inherits:
Object
  • Object
show all
Defined in:
lib/rehtml/tokenizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ Tokenizer

Create a new Tokenizer for the given text.



17
18
19
20
# File 'lib/rehtml/tokenizer.rb', line 17

def initialize(html)
  @scanner = Scanner.new(html)
  @bpos = 0
end

Instance Method Details

#nextObject

Return the next token in the sequence, or nil if there are no more tokens in the stream.



24
25
26
27
# File 'lib/rehtml/tokenizer.rb', line 24

def next
  return nil if @scanner.eos?
  add_parse_info(@scanner.check(/<\S/) ? scan_element : scan_text)
end