Changeset 146
- Timestamp:
- 06/02/2007 00:48:14 (18 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
ext/hpricot_scan/hpricot_common.rl (modified) (2 diffs)
-
lib/hpricot/parse.rb (modified) (1 diff)
-
lib/hpricot/xchar.rb (modified) (1 diff)
-
test/test_parser.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/hpricot_scan/hpricot_common.rl
r126 r146 37 37 XmlYesNo = ("yes" | "no") >_aval %xmlsd ; 38 38 XmlSDDecl = space+ "standalone" space* "=" space* ("'" XmlYesNo "'" | '"' XmlYesNo '"') ; 39 XmlDecl = "<?xml" XmlVersionInfo XmlEncodingDecl? XmlSDDecl? space* "? >" ;39 XmlDecl = "<?xml" XmlVersionInfo XmlEncodingDecl? XmlSDDecl? space* "?"? ">" ; 40 40 41 41 SystemLiteral = '"' [^"]* >_aval %sysid '"' | "'" [^']* >_aval %sysid "'" ; … … 45 45 DocType = "<!DOCTYPE" space+ NameCap (space+ ExternalID)? space* ("[" [^\]]* "]" space*)? ">" ; 46 46 StartXmlProcIns = "<?" Name >{ TEXT_PASS(); } space+ ; 47 EndXmlProcIns = "? >" ;47 EndXmlProcIns = "?"? ">" ; 48 48 49 49 html_comment := |* -
trunk/lib/hpricot/parse.rb
r136 r146 54 54 token[0] = :text 55 55 token[1] = token[3] if token[3] 56 end 57 58 if token[0] == :emptytag and ElementContent[token[1].send(conv)] != :EMPTY and !opts[:xml] 59 token[0] = :stag 56 60 end 57 61 -
trunk/lib/hpricot/xchar.rb
r145 r146 86 86 # XML unescape 87 87 def uxs(str) 88 str.gsub(/\&\w+;/) { |x| (XChar::PREDEFINED_U[x] || ??).chr }. 88 str.to_s. 89 gsub(/\&\w+;/) { |x| (XChar::PREDEFINED_U[x] || ??).chr }. 89 90 gsub(/\&\#(\d+);/) { [$1.to_i].pack("U*") } 90 91 end -
trunk/test/test_parser.rb
r144 r146 115 115 assert_equal 59, @boingboing.search("h3[text()!='College kids reportedly taking more smart drugs']").length 116 116 assert_equal 17, @boingboing.search("h3[text()$='s']").length 117 assert_equal 12 8, @boingboing.search("p[text()]").length117 assert_equal 129, @boingboing.search("p[text()]").length 118 118 assert_equal 211, @boingboing.search("p").length 119 119 end … … 155 155 assert_equal 18, @boingboing.search("//script").length 156 156 divs = @boingboing.search("//script/../div") 157 assert_equal 2, divs.length 158 assert_equal 1, divs.search('a').length 157 assert_equal 1, divs.length 159 158 imgs = @boingboing.search('//div/p/a/img') 160 159 assert_equal 15, imgs.length … … 326 325 end 327 326 327 # ticket #84 by jamezilla 328 def test_screwed_xmlns 329 doc = Hpricot(<<-edoc) 330 <?xml:namespace prefix = cwi /> 331 <html><body>HAI</body></html> 332 edoc 333 assert_equal "HAI", doc.at("body").inner_text 334 end 335 336 # Reported by Jonathan Nichols on the Hpricot list (24 May 2007) 337 def test_self_closed_form 338 doc = Hpricot(<<-edoc) 339 <body> 340 <form action="/loginRegForm" name="regForm" method="POST" /> 341 <input type="button"> 342 </form> 343 </body> 344 edoc 345 assert_equal "button", doc.at("//form/input")['type'] 346 end 347 328 348 def test_filters 329 349 @basic = Hpricot.parse(TestFiles::BASIC)
