Class: HTML2FB::Parser
- Inherits:
-
Object
- Object
- HTML2FB::Parser
- Defined in:
- lib/parser.rb
Instance Method Summary collapse
-
#initialize(conf) ⇒ Parser
constructor
A new instance of Parser.
- #parse(txt) ⇒ Object
Constructor Details
#initialize(conf) ⇒ Parser
Returns a new instance of Parser.
11 12 13 |
# File 'lib/parser.rb', line 11 def initialize(conf) @conf=conf end |
Instance Method Details
#parse(txt) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/parser.rb', line 15 def parse(txt) puts "Parsing HTML" pdoc=Hpricot(txt) doc=Document.new puts "Removing garbage elements" remove_objs(pdoc) ti=pdoc.at('title') doc.title= ti.extract_text.strip unless ti.nil? # pdoc.search('//h3').each do |e| # doc.content.push(e.inner_text) # end puts "Building TOC" parse_text(pdoc,doc) # puts green(bold(doc.pretty_inspect)) return doc end |