Changeset 147
- Timestamp:
- 06/04/2007 23:10:53 (18 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 modified
-
lib/hpricot/parse.rb (modified) (2 diffs)
-
test/files/tenderlove.html (added)
-
test/test_parser.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/hpricot/parse.rb
r146 r147 51 51 Hpricot.scan(input) do |token| 52 52 if stack.last[5] == :CDATA and ![:procins, :comment, :cdata].include?(token[0]) and 53 !(token[0] == :etag and token[1]. send(conv) == stack.last[0])53 !(token[0] == :etag and token[1].casecmp(stack.last[0]).zero?) 54 54 token[0] = :text 55 55 token[1] = token[3] if token[3] 56 56 end 57 57 58 if token[0] == :emptytag and ElementContent[token[1].send(conv)] != :EMPTY and !opts[:xml]58 if !opts[:xml] and token[0] == :emptytag and ElementContent[token[1].downcase] != :EMPTY 59 59 token[0] = :stag 60 end 61 62 # TODO: downcase instead when parsing attributes? 63 if !opts[:xml] and token[2].is_a?(Hash) 64 token[2] = token[2].inject({}) { |hsh,(k,v)| hsh[k.downcase] = v; hsh } 60 65 end 61 66 … … 66 71 end 67 72 68 stagname = token[0] = token[1] .send(conv)73 stagname = token[0] = token[1] = token[1].send(conv) 69 74 if ElementContent[stagname] == :EMPTY and !opts[:xml] 70 75 token[0] = :emptytag -
trunk/test/test_parser.rb
r146 r147 174 174 end 175 175 176 def test_tag_case 177 @tenderlove = Hpricot.parse(TestFiles::TENDERLOVE) 178 assert_equal 2, @tenderlove.search('//a').length 179 assert_equal 2, @tenderlove.search('//area').length 180 assert_equal 2, @tenderlove.search('//meta').length 181 end 182 176 183 def test_alt_predicates 177 184 @boingboing = Hpricot.parse(TestFiles::BOINGBOING)
