Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ruby/gems/1.9.1/gems/hpricot-0.8.1/lib/hpricot/parse.rb
blob: 4c9711ebeec8145f34c3f6afbc5a358f337278fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'hpricot/htmlinfo'

def Hpricot(input = nil, opts = {}, &blk)
  Hpricot.make(input, opts, &blk)
end

module Hpricot
  # Exception class used for any errors related to deficiencies in the system when
  # handling the character encodings of a document.
  class EncodingError < StandardError; end

  # Hpricot.parse parses <i>input</i> and return a document tree.
  # represented by Hpricot::Doc.
  def Hpricot.parse(input = nil, opts = {}, &blk)
    make(input, opts, &blk)
  end

  # Hpricot::XML parses <i>input</i>, disregarding all the HTML rules
  # and returning a document tree.
  def Hpricot.XML(input = nil, opts = {}, &blk)
    opts.merge! :xml => true
    make(input, opts, &blk)
  end

  # :stopdoc:

  def Hpricot.make(input = nil, opts = {}, &blk)
    if blk
      doc = Hpricot.build(&blk)
      doc.instance_variable_set("@options", opts)
      doc
    else
      Hpricot.scan(input, opts)
    end
  end

  # :startdoc:
end