Hpricot

 Permission is granted for use, copying, modification, distribution,
 and distribution of modified versions of this work as long as the
 above copyright notice is included.

++


Constants

FORM_TAGS
SELF_CLOSING_TAGS
AttrCore

Common sets of attributes.

AttrI18n
AttrEvents
AttrFocus
AttrHAlign
AttrVAlign
Attrs

Public Class Methods

XML(input = nil, opts = {}, &blk) click to toggle source

Hpricot::XML parses input, disregarding all the HTML rules and returning a document tree.

    # File lib/hpricot/parse.rb, line 20
20:   def Hpricot.XML(input = nil, opts = {}, &blk)
21:     opts.merge! :xml => true
22:     make(input, opts, &blk)
23:   end
build(ele = Doc.new, assigns = {}, &blk) click to toggle source
    # File lib/hpricot/builder.rb, line 14
14:   def self.build(ele = Doc.new, assigns = {}, &blk)
15:     ele.extend Builder
16:     assigns.each do |k, v|
17:       ele.instance_variable_set("@#{k}", v)
18:     end
19:     ele.instance_eval(&blk)
20:     ele
21:   end
parse(input = nil, opts = {}, &blk) click to toggle source

Hpricot.parse parses input and return a document tree. represented by Hpricot::Doc.

    # File lib/hpricot/parse.rb, line 14
14:   def Hpricot.parse(input = nil, opts = {}, &blk)
15:     make(input, opts, &blk)
16:   end
uxs(str) click to toggle source

XML unescape

    # File lib/hpricot/builder.rb, line 8
 8:   def self.uxs(str)
 9:     str.to_s.
10:         gsub(/\&(\w+);/) { [NamedCharacters[$1] || ??].pack("U*") }.
11:         gsub(/\&\#(\d+);/) { [$1.to_i].pack("U*") }
12:   end
uxs(str) click to toggle source

XML unescape

    # File lib/hpricot/xchar.rb, line 87
87:     def uxs(str)
88:       str.to_s.
89:           gsub(/\&\w+;/) { |x| (XChar::PREDEFINED_U[x] || ??).chr }.
90:           gsub(/\&\#(\d+);/) { [$1.to_i].pack("U*") }
91:     end
xchr(str) click to toggle source

XML escaped version of chr

    # File lib/hpricot/xchar.rb, line 70
70:     def xchr(str)
71:       n = XChar::CP1252[str] || str
72:       case n when *XChar::VALID
73:         XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};")
74:       else
75:         '*'
76:       end
77:     end
xs(str) click to toggle source

XML escaped version of to_s

    # File lib/hpricot/xchar.rb, line 80
80:     def xs(str)
81:       str.to_s.unpack('U*').map {|n| xchr(n)}.join # ASCII, UTF-8
82:     rescue
83:       str.to_s.unpack('C*').map {|n| xchr(n)}.join # ISO-8859-1, WIN-1252
84:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.