Many Minor Fixes

Fixed a whole bunch of minor stuff.
Had a go at getting some of the plethora of broken tests to pass.
This commit is contained in:
Jacques Distler 2007-06-12 17:37:55 -05:00
parent 0ddd422059
commit 2da672ec5b
13 changed files with 108 additions and 84 deletions

17
vendor/plugins/HTML5lib/LICENSE vendored Normal file
View file

@ -0,0 +1,17 @@
Copyright (c) 2006-2007 The Authors
Contributers:
James Graham - jg307@cam.ac.uk
Anne van Kesteren - annevankesteren@gmail.com
Lachlan Hunt - lachlan.hunt@lachy.id.au
Matt McDonald - kanashii@kanashii.ca
Sam Ruby - rubys@intertwingly.net
Ian Hickson (Google) - ian@hixie.ch
Thomas Broyer - t.broyer@ltgt.net
Jacques Distler - distler@golem.ph.utexas.edu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -27,6 +27,8 @@ module HTML5lib
handle_end %w( address blockquote center div dl fieldset listing menu ol pre ul ) => 'Block'
handle_end HEADING_ELEMENTS => 'Heading'
handle_end %w( a b big em font i nobr s small strike strong tt u ) => 'Formatting'
handle_end %w( head frameset select optgroup option table caption colgroup col thead tfoot tbody tr td th ) => 'Misplaced'

View file

@ -78,7 +78,7 @@ module HTML5lib
class Element < Node
def to_s
"<%s>" % name
"<#{name}>"
end
def printTree indent=0

View file

@ -32,19 +32,19 @@ def parse(opts, args)
if opts.profile
require 'profiler'
Profiler__::start_profile
p.parse(f)
p.send(opts.parsemethod,f)
Profiler__::stop_profile
Profiler__::print_profile($stderr)
elsif opts.time
require 'time'
t0 = Time.new
document = p.parse(f)
document = p.send(opts.parsemethod,f)
t1 = Time.new
printOutput(p, document, opts)
t2 = Time.new
puts "\n\nRun took: %fs (plus %fs to print the output)"%[t1-t0, t2-t1]
else
document = p.parse(f)
document = p.send(opts.parsemethod,f)
printOutput(p, document, opts)
end
end
@ -63,7 +63,8 @@ def printOutput(parser, document, opts)
when :hilite
print document.hilite
when :tree
print parser.tree.testSerializer(document)
document = [document] unless document.respond_to?(:each)
document.each {|fragment| puts parser.tree.testSerializer(fragment)}
end
if opts.error
@ -71,7 +72,7 @@ def printOutput(parser, document, opts)
for pos, message in parser.errors
errList << ("Line %i Col %i"%pos + " " + message)
end
$stderr.write("\nParse errors:\n" + errList.join("\n")+"\n")
$stdout.write("\nParse errors:\n" + errList.join("\n")+"\n")
end
end
@ -83,6 +84,7 @@ options.output = :tree
options.treebuilder = 'simpletree'
options.error = false
options.encoding = false
options.parsemethod = :parse
require 'optparse'
opts = OptionParser.new do |opts|
@ -110,6 +112,10 @@ opts = OptionParser.new do |opts|
options.error = error
end
opts.on("-f", "--fragment", "Parse as a fragment") do |parse|
options.parsemethod = :parseFragment
end
opts.on("-x", "--xml", "output as xml") do |xml|
options.output = :xml
options.treebuilder = "rexml"

View file

@ -12,7 +12,7 @@ begin
rescue LoadError
end
$CHECK_PARSER_ERRORS = false
$CHECK_PARSER_ERRORS = ARGV.delete('-p')
puts 'Testing tree builders: ' + $tree_types_to_test * ', '
@ -55,6 +55,7 @@ class Html5ParserTestCase < Test::Unit::TestCase
'Line: %i Col: %i %s' % [line, col, message]
end
assert_equal expected_errors.length, parser.errors.length, [
'Input', input + "\n",
'Expected errors:', expected_errors.join("\n"),
'Actual errors:', actual_errors.join("\n")
].join("\n")