Changeset 130
- Timestamp:
- 04/03/2007 23:48:46 (20 months ago)
- Location:
- trunk
- Files:
-
- 5 modified
-
lib/hpricot/elements.rb (modified) (1 diff)
-
lib/hpricot/inspect.rb (modified) (1 diff)
-
lib/hpricot/parse.rb (modified) (4 diffs)
-
lib/hpricot/tag.rb (modified) (1 diff)
-
test/test_xml.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/hpricot/elements.rb
r123 r130 223 223 nodes, = Elements.filter(nodes, m[2], false) 224 224 else 225 meth = "filter[#{m[0]}#{m[1]}]" 226 if Traverse.method_defined? meth225 meth = "filter[#{m[0]}#{m[1]}]" unless m[0].empty? 226 if meth and Traverse.method_defined? meth 227 227 args = m[2..-1] 228 228 else -
trunk/lib/hpricot/inspect.rb
r100 r130 61 61 q.text @name 62 62 63 if @ attributes64 @ attributes.each {|n, t|63 if @raw_attributes 64 @raw_attributes.each {|n, t| 65 65 q.breakable 66 q.text "#{n}=\"#{ t}\""66 q.text "#{n}=\"#{Hpricot.uxs(t)}\"" 67 67 } 68 68 end -
trunk/lib/hpricot/parse.rb
r123 r130 29 29 raise ArgumentError, "An Hpricot document must be built from an input source (a String) or a block." 30 30 end 31 32 trans = opts[:xml] ? :to_s : :downcase 31 33 32 34 fragment = … … 49 51 Hpricot.scan(input) do |token| 50 52 if stack.last[5] == :CDATA and ![:procins, :comment, :cdata].include?(token[0]) and 51 !(token[0] == :etag and token[1]. downcase== stack.last[0])53 !(token[0] == :etag and token[1].send(trans) == stack.last[0]) 52 54 token[0] = :text 53 55 token[1] = token[3] if token[3] … … 60 62 end 61 63 62 stagname = token[0] = token[1]. downcase64 stagname = token[0] = token[1].send(trans) 63 65 if ElementContent[stagname] == :EMPTY and !opts[:xml] 64 66 token[0] = :emptytag … … 105 107 end 106 108 end 109 unless opts[:xml] 110 case token[2] when Hash 111 token[2] = token[2].inject({}) { |hsh,(k,v)| hsh[k.downcase] = v; hsh } 112 end 113 end 107 114 stack << [stagname, token, [], excluded_tags, included_tags, uncontainable_tags] 108 115 end 109 116 when :etag 110 etagname = token[0] = token[1]. downcase117 etagname = token[0] = token[1].send(trans) 111 118 if opts[:xhtml_strict] and not ElementContent.has_key? etagname 112 119 etagname = token[0] = "div" -
trunk/lib/hpricot/tag.rb
r127 r130 93 93 class STag < BaseEle 94 94 def initialize(name, attributes=nil) 95 @name = name.to_s.downcase 96 @raw_attributes = {} 97 if attributes 98 @raw_attributes = attributes.inject({}) { |hsh,(k,v)| hsh[k.to_s.downcase] = v; hsh } 99 end 95 @name = name.to_s 96 @raw_attributes = attributes || {} 100 97 end 101 98 alterable :name, :raw_attributes -
trunk/test/test_xml.rb
r114 r130 14 14 end 15 15 16 def test_tag_case 16 # make sure XML doesn't get downcased 17 def test_casing 17 18 doc = Hpricot::XML(TestFiles::WHY) 18 # Hpricot currently downcase-s everything, so this test would fail: 19 assert_equal "hourly", (doc.at "sy:updatePeriod").inner_html 20 assert_equal 1, (doc/"guid[@isPermaLink]").length 21 end 19 22 20 # assert_equal "hourly", (doc.at "sy:updatePeriod").inner_html 23 # be sure tags named "text" are ok 24 def test_text_tags 25 doc = Hpricot::XML("<feed><title>City Poisoned</title><text>Rita Lee has poisoned Brazil.</text></feed>") 26 assert_equal "City Poisoned", (doc/"title").text 21 27 end 22 28 end
