Update to latest HTML5lib
Fix that Tokenizer bug for real this time.
This commit is contained in:
parent
f3a89556c4
commit
ed68d975df
53 changed files with 11569 additions and 2603 deletions
|
@ -12,13 +12,13 @@ module HTML5
|
|||
end
|
||||
|
||||
def processCharacters(data)
|
||||
parse_error(_('Unexpected non-space characters in the after body phase.'))
|
||||
parse_error("unexpected-char-after-body")
|
||||
@parser.phase = @parser.phases[:inBody]
|
||||
@parser.phase.processCharacters(data)
|
||||
end
|
||||
|
||||
def processStartTag(name, attributes)
|
||||
parse_error(_("Unexpected start tag token (#{name}) in the after body phase."))
|
||||
parse_error("unexpected-start-tag-after-body", {"name" => name})
|
||||
@parser.phase = @parser.phases[:inBody]
|
||||
@parser.phase.processStartTag(name, attributes)
|
||||
end
|
||||
|
@ -37,7 +37,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagOther(name)
|
||||
parse_error(_("Unexpected end tag token (#{name}) in the after body phase."))
|
||||
parse_error("unexpected-end-tag-after-body", {"name" => name})
|
||||
@parser.phase = @parser.phases[:inBody]
|
||||
@parser.phase.processEndTag(name)
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module HTML5
|
|||
handle_end 'html'
|
||||
|
||||
def processCharacters(data)
|
||||
parse_error(_('Unexpected non-space characters in the after frameset phase. Ignored.'))
|
||||
parse_error("unexpected-char-after-frameset")
|
||||
end
|
||||
|
||||
def startTagNoframes(name, attributes)
|
||||
|
@ -18,7 +18,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagOther(name, attributes)
|
||||
parse_error(_("Unexpected start tag (#{name}) in the after frameset phase. Ignored."))
|
||||
parse_error("unexpected-start-tag-after-frameset", {"name" => name})
|
||||
end
|
||||
|
||||
def endTagHtml(name)
|
||||
|
@ -27,8 +27,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagOther(name)
|
||||
parse_error(_("Unexpected end tag (#{name}) in the after frameset phase. Ignored."))
|
||||
parse_error("unexpected-end-tag-after-frameset", {"name" => name})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -26,7 +26,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagFromHead(name, attributes)
|
||||
parse_error(_("Unexpected start tag (#{name}) that can be in head. Moved."))
|
||||
parse_error("unexpected-start-tag-out-of-my-head", {"name" => name})
|
||||
@parser.phase = @parser.phases[:inHead]
|
||||
@parser.phase.processStartTag(name, attributes)
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagOther(name)
|
||||
parse_error(_("Unexpected end tag (#{name}) after the (implied) root element."))
|
||||
parse_error("end-tag-after-implied-root", {"name" => name})
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -100,12 +100,12 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagTitle(name, attributes)
|
||||
parse_error(_("Unexpected start tag (#{name}) that belongs in the head. Moved."))
|
||||
parse_error("unexpected-start-tag-out-of-my-head", {"name" => name})
|
||||
@parser.phases[:inHead].processStartTag(name, attributes)
|
||||
end
|
||||
|
||||
def startTagBody(name, attributes)
|
||||
parse_error(_('Unexpected start tag (body).'))
|
||||
parse_error("unexpected-start-tag", {"name" => "body"})
|
||||
|
||||
if (@tree.open_elements.length == 1 || @tree.open_elements[1].name != 'body')
|
||||
assert @parser.inner_html
|
||||
|
@ -126,7 +126,7 @@ module HTML5
|
|||
|
||||
def startTagForm(name, attributes)
|
||||
if @tree.formPointer
|
||||
parse_error(_('Unexpected start tag (form). Ignored.'))
|
||||
parse_error("Unexpected start tag (form). Ignored.")
|
||||
else
|
||||
endTagP('p') if in_scope?('p')
|
||||
@tree.insert_element(name, attributes)
|
||||
|
@ -143,7 +143,10 @@ module HTML5
|
|||
if stopName.include?(node.name)
|
||||
poppedNodes = (0..i).collect { @tree.open_elements.pop }
|
||||
if i >= 1
|
||||
parse_error(_("Missing end tag%s (%s)" % [(i>1 ? 's' : ''), poppedNodes.reverse.map{|item| item.name}.join(', ')]))
|
||||
parse_error(
|
||||
i == 1 ? "missing-end-tag" : "missing-end-tags",
|
||||
{"name" => poppedNodes[0..-1].collect{|n| n.name}.join(", ")})
|
||||
|
||||
end
|
||||
break
|
||||
end
|
||||
|
@ -169,7 +172,7 @@ module HTML5
|
|||
# Uncomment the following for IE7 behavior:
|
||||
# HEADING_ELEMENTS.each do |element|
|
||||
# if in_scope?(element)
|
||||
# parse_error(_("Unexpected start tag (#{name})."))
|
||||
# parse_error("unexpected-start-tag", {"name" => name})
|
||||
#
|
||||
# remove_open_elements_until do |element|
|
||||
# HEADING_ELEMENTS.include?(element.name)
|
||||
|
@ -183,7 +186,7 @@ module HTML5
|
|||
|
||||
def startTagA(name, attributes)
|
||||
if afeAElement = @tree.elementInActiveFormattingElements('a')
|
||||
parse_error(_('Unexpected start tag (a) implies end tag (a).'))
|
||||
parse_error("unexpected-start-tag-implies-end-tag", {"startName" => "a", "endName" => "a"})
|
||||
endTagFormatting('a')
|
||||
@tree.open_elements.delete(afeAElement) if @tree.open_elements.include?(afeAElement)
|
||||
@tree.activeFormattingElements.delete(afeAElement) if @tree.activeFormattingElements.include?(afeAElement)
|
||||
|
@ -200,7 +203,7 @@ module HTML5
|
|||
def startTagNobr(name, attributes)
|
||||
@tree.reconstructActiveFormattingElements
|
||||
if in_scope?('nobr')
|
||||
parse_error(_('Unexpected start tag (nobr) implies end tag (nobr).'))
|
||||
parse_error("unexpected-start-tag-implies-end-tag", {"startName" => "nobr", "endName" => "nobr"})
|
||||
processEndTag('nobr')
|
||||
# XXX Need tests that trigger the following
|
||||
@tree.reconstructActiveFormattingElements
|
||||
|
@ -210,7 +213,7 @@ module HTML5
|
|||
|
||||
def startTagButton(name, attributes)
|
||||
if in_scope?('button')
|
||||
parse_error(_('Unexpected start tag (button) implied end tag (button).'))
|
||||
parse_error("unexpected-start-tag-implies-end-tag", {"startName" => "button", "endName" => "button"})
|
||||
processEndTag('button')
|
||||
@parser.phase.processStartTag(name, attributes)
|
||||
else
|
||||
|
@ -252,7 +255,7 @@ module HTML5
|
|||
|
||||
def startTagImage(name, attributes)
|
||||
# No really...
|
||||
parse_error(_('Unexpected start tag (image). Treated as img.'))
|
||||
parse_error("unexpected-start-tag-treated-as", {"originalName" => "image", "newName" => "img"})
|
||||
processStartTag('img', attributes)
|
||||
end
|
||||
|
||||
|
@ -267,7 +270,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagIsindex(name, attributes)
|
||||
parse_error(_("Unexpected start tag isindex. Don't use it!"))
|
||||
parse_error("deprecated-tag", {"name" => "isindex"})
|
||||
return if @tree.formPointer
|
||||
processStartTag('form', {})
|
||||
processStartTag('hr', {})
|
||||
|
@ -310,13 +313,13 @@ module HTML5
|
|||
# "caption", "col", "colgroup", "frame", "frameset", "head",
|
||||
# "option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
|
||||
# "tr", "noscript"
|
||||
parse_error(_("Unexpected start tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-start-tag-ignored", {"name" => name})
|
||||
end
|
||||
|
||||
def startTagNew(name, attributes)
|
||||
# New HTML5 elements, "event-source", "section", "nav",
|
||||
# "article", "aside", "header", "footer", "datagrid", "command"
|
||||
sys.stderr.write("Warning: Undefined behaviour for start tag #{name}")
|
||||
# $stderr.puts("Warning: Undefined behaviour for start tag #{name}")
|
||||
startTagOther(name, attributes)
|
||||
#raise NotImplementedError
|
||||
end
|
||||
|
@ -328,7 +331,7 @@ module HTML5
|
|||
|
||||
def endTagP(name)
|
||||
@tree.generateImpliedEndTags('p') if in_scope?('p')
|
||||
parse_error(_('Unexpected end tag (p).')) unless @tree.open_elements.last.name == 'p'
|
||||
parse_error("unexpected-end-tag", {"name" => "p"}) unless @tree.open_elements.last.name == 'p'
|
||||
if in_scope?('p')
|
||||
@tree.open_elements.pop while in_scope?('p')
|
||||
else
|
||||
|
@ -347,7 +350,9 @@ module HTML5
|
|||
return
|
||||
end
|
||||
unless @tree.open_elements.last.name == 'body'
|
||||
parse_error(_("Unexpected end tag (body). Missing end tag (#{@tree.open_elements[-1].name})."))
|
||||
parse_error("expected-one-end-tag-but-got-another",
|
||||
{"expectedName" => "body",
|
||||
"gotName" => @tree.open_elements.last.name})
|
||||
end
|
||||
@parser.phase = @parser.phases[:afterBody]
|
||||
end
|
||||
|
@ -364,7 +369,7 @@ module HTML5
|
|||
@tree.generateImpliedEndTags if in_scope?(name)
|
||||
|
||||
unless @tree.open_elements.last.name == name
|
||||
parse_error(_("End tag (#{name}) seen too early. Expected other end tag."))
|
||||
parse_error("end-tag-too-early", {"name" => name})
|
||||
end
|
||||
|
||||
if in_scope?(name)
|
||||
|
@ -377,7 +382,7 @@ module HTML5
|
|||
@tree.generateImpliedEndTags
|
||||
end
|
||||
if @tree.open_elements.last.name != name
|
||||
parse_error(_("End tag (form) seen too early. Ignored."))
|
||||
parse_error("end-tag-too-early-ignored", {"name" => "form"})
|
||||
else
|
||||
@tree.open_elements.pop
|
||||
end
|
||||
|
@ -389,7 +394,7 @@ module HTML5
|
|||
@tree.generateImpliedEndTags(name) if in_scope?(name)
|
||||
|
||||
unless @tree.open_elements.last.name == name
|
||||
parse_error(_("End tag (#{name}) seen too early. " + 'Expected other end tag.'))
|
||||
parse_error("end-tag-too-early", {"name" => name})
|
||||
end
|
||||
|
||||
remove_open_elements_until(name) if in_scope?(name)
|
||||
|
@ -404,7 +409,7 @@ module HTML5
|
|||
end
|
||||
|
||||
unless @tree.open_elements.last.name == name
|
||||
parse_error(_("Unexpected end tag (#{name}). Expected other end tag."))
|
||||
parse_error("end-tag-too-early", {"name" => name})
|
||||
end
|
||||
|
||||
HEADING_ELEMENTS.each do |element|
|
||||
|
@ -423,18 +428,18 @@ module HTML5
|
|||
# Step 1 paragraph 1
|
||||
afeElement = @tree.elementInActiveFormattingElements(name)
|
||||
if !afeElement or (@tree.open_elements.include?(afeElement) && !in_scope?(afeElement.name))
|
||||
parse_error(_("End tag (#{name}) violates step 1, paragraph 1 of the adoption agency algorithm."))
|
||||
parse_error("adoption-agency-1.1", {"name" => name})
|
||||
return
|
||||
# Step 1 paragraph 2
|
||||
elsif not @tree.open_elements.include?(afeElement)
|
||||
parse_error(_("End tag (#{name}) violates step 1, paragraph 2 of the adoption agency algorithm."))
|
||||
parse_error("adoption-agency-1.2", {"name" => name})
|
||||
@tree.activeFormattingElements.delete(afeElement)
|
||||
return
|
||||
end
|
||||
|
||||
# Step 1 paragraph 3
|
||||
if afeElement != @tree.open_elements.last
|
||||
parse_error(_("End tag (#{name}) violates step 1, paragraph 3 of the adoption agency algorithm."))
|
||||
parse_error("adoption-agency-1.3", {"name" => name})
|
||||
end
|
||||
|
||||
# Step 2
|
||||
|
@ -531,7 +536,7 @@ module HTML5
|
|||
@tree.generateImpliedEndTags if in_scope?(name)
|
||||
|
||||
unless @tree.open_elements.last.name == name
|
||||
parse_error(_("Unexpected end tag (#{name}). Expected other end tag first."))
|
||||
parse_error("end-tag-too-early", {"name" => name})
|
||||
end
|
||||
|
||||
if in_scope?(name)
|
||||
|
@ -543,11 +548,12 @@ module HTML5
|
|||
|
||||
def endTagMisplaced(name)
|
||||
# This handles elements with end tags in other insertion modes.
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
|
||||
def endTagBr(name)
|
||||
parse_error(_("Unexpected end tag (br). Treated as br element."))
|
||||
parse_error("unexpected-end-tag-treated-as",
|
||||
{"originalName" => "br", "newName" => "br element"})
|
||||
@tree.reconstructActiveFormattingElements
|
||||
@tree.insert_element(name, {})
|
||||
@tree.open_elements.pop()
|
||||
|
@ -555,21 +561,21 @@ module HTML5
|
|||
|
||||
def endTagNone(name)
|
||||
# This handles elements with no end tag.
|
||||
parse_error(_("This tag (#{name}) has no end tag"))
|
||||
parse_error("no-end-tag", {"name" => name})
|
||||
end
|
||||
|
||||
def endTagCdataTextAreaXmp(name)
|
||||
if @tree.open_elements.last.name == name
|
||||
@tree.open_elements.pop
|
||||
else
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
end
|
||||
|
||||
def endTagNew(name)
|
||||
# New HTML5 elements, "event-source", "section", "nav",
|
||||
# "article", "aside", "header", "footer", "datagrid", "command"
|
||||
STDERR.puts "Warning: Undefined behaviour for end tag #{name}"
|
||||
# STDERR.puts "Warning: Undefined behaviour for end tag #{name}"
|
||||
endTagOther(name)
|
||||
#raise NotImplementedError
|
||||
end
|
||||
|
@ -581,7 +587,7 @@ module HTML5
|
|||
@tree.generateImpliedEndTags
|
||||
|
||||
unless @tree.open_elements.last.name == name
|
||||
parse_error(_("Unexpected end tag (#{name})."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
|
||||
remove_open_elements_until {|element| element == node }
|
||||
|
@ -589,7 +595,7 @@ module HTML5
|
|||
break
|
||||
else
|
||||
if (SPECIAL_ELEMENTS + SCOPING_ELEMENTS).include?(node.name)
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
break
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,7 +39,9 @@ module HTML5
|
|||
@tree.generateImpliedEndTags
|
||||
|
||||
unless @tree.open_elements[-1].name == 'caption'
|
||||
parse_error(_("Unexpected end tag (caption). Missing end tags."))
|
||||
parse_error("expected-one-end-tag-but-got-another",
|
||||
{"gotName" => "caption",
|
||||
"expectedNmae" => @tree.open_elements.last.name})
|
||||
end
|
||||
|
||||
remove_open_elements_until('caption')
|
||||
|
@ -57,7 +59,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagIgnore(name)
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
|
||||
def endTagOther(name)
|
||||
|
|
|
@ -33,7 +33,7 @@ module HTML5
|
|||
if in_scope?(name, true)
|
||||
@tree.generateImpliedEndTags(name)
|
||||
if @tree.open_elements.last.name != name
|
||||
parse_error("Got table cell end tag (#{name}) while required end tags are missing.")
|
||||
parse_error("unexpected-cell-end-tag", {"name" => name})
|
||||
|
||||
remove_open_elements_until(name)
|
||||
else
|
||||
|
@ -42,12 +42,12 @@ module HTML5
|
|||
@tree.clearActiveFormattingElements
|
||||
@parser.phase = @parser.phases[:inRow]
|
||||
else
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
end
|
||||
|
||||
def endTagIgnore(name)
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
|
||||
def endTagImply(name)
|
||||
|
|
|
@ -42,7 +42,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagCol(name)
|
||||
parse_error(_('Unexpected end tag (col). col has no end tag.'))
|
||||
parse_error("no-end-tag", {"name" => "col"})
|
||||
end
|
||||
|
||||
def endTagOther(name)
|
||||
|
|
|
@ -10,7 +10,7 @@ module HTML5
|
|||
handle_end 'frameset', 'noframes'
|
||||
|
||||
def processCharacters(data)
|
||||
parse_error(_('Unexpected characters in the frameset phase. Characters ignored.'))
|
||||
parse_error("unexpected-char-in-frameset")
|
||||
end
|
||||
|
||||
def startTagFrameset(name, attributes)
|
||||
|
@ -27,13 +27,14 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagOther(name, attributes)
|
||||
parse_error(_("Unexpected start tag token (#{name}) in the frameset phase. Ignored"))
|
||||
parse_error("unexpected-start-tag-in-frameset",
|
||||
{"name" => name})
|
||||
end
|
||||
|
||||
def endTagFrameset(name)
|
||||
if @tree.open_elements.last.name == 'html'
|
||||
# inner_html case
|
||||
parse_error(_("Unexpected end tag token (frameset) in the frameset phase (inner_html)."))
|
||||
parse_error("unexpected-frameset-in-frameset-innerhtml")
|
||||
else
|
||||
@tree.open_elements.pop
|
||||
end
|
||||
|
@ -50,8 +51,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagOther(name)
|
||||
parse_error(_("Unexpected end tag token (#{name}) in the frameset phase. Ignored."))
|
||||
parse_error("unexpected-end-tag-in-frameset", {"name" => name})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -12,7 +12,7 @@ module HTML5
|
|||
|
||||
def process_eof
|
||||
if ['title', 'style', 'script'].include?(name = @tree.open_elements.last.name)
|
||||
parse_error(_("Unexpected end of file. Expected end tag (#{name})."))
|
||||
parse_error("expected-named-closing-tag-but-got-eof", {"name" => @tree.open_elements.last.name})
|
||||
@tree.open_elements.pop
|
||||
end
|
||||
anything_else
|
||||
|
@ -29,7 +29,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagHead(name, attributes)
|
||||
parse_error(_('Unexpected start tag head in existing head. Ignored'))
|
||||
parse_error("two-heads-are-not-better-than-one")
|
||||
end
|
||||
|
||||
def startTagTitle(name, attributes)
|
||||
|
@ -93,7 +93,7 @@ module HTML5
|
|||
if @tree.open_elements.last.name == 'head'
|
||||
@tree.open_elements.pop
|
||||
else
|
||||
parse_error(_("Unexpected end tag (head). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => "head"})
|
||||
end
|
||||
@parser.phase = @parser.phases[:afterHead]
|
||||
end
|
||||
|
@ -107,12 +107,12 @@ module HTML5
|
|||
if @tree.open_elements.last.name == name
|
||||
@tree.open_elements.pop
|
||||
else
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
end
|
||||
|
||||
def endTagOther(name)
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
|
||||
def anything_else
|
||||
|
|
|
@ -62,7 +62,8 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagIgnore(name)
|
||||
parse_error(_("Unexpected end tag (#{name}) in the row phase. Ignored."))
|
||||
parse_error("unexpected-end-tag-in-table-row",
|
||||
{"name" => name})
|
||||
end
|
||||
|
||||
def endTagOther(name)
|
||||
|
@ -74,7 +75,8 @@ module HTML5
|
|||
# XXX unify this with other table helper methods
|
||||
def clearStackToTableRowContext
|
||||
until %w[tr html].include?(name = @tree.open_elements.last.name)
|
||||
parse_error(_("Unexpected implied end tag (#{name}) in the row phase."))
|
||||
parse_error("unexpected-implied-end-tag-in-table-row",
|
||||
{"name" => @tree.open_elements.last.name})
|
||||
@tree.open_elements.pop
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,19 +26,19 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagSelect(name, attributes)
|
||||
parse_error(_('Unexpected start tag (select) in the select phase implies select start tag.'))
|
||||
parse_error("unexpected-select-in-select")
|
||||
endTagSelect('select')
|
||||
end
|
||||
|
||||
def startTagOther(name, attributes)
|
||||
parse_error(_('Unexpected start tag token (#{name}) in the select phase. Ignored.'))
|
||||
parse_error("unexpected-start-tag-in-select", {"name" => name})
|
||||
end
|
||||
|
||||
def endTagOption(name)
|
||||
if @tree.open_elements.last.name == 'option'
|
||||
@tree.open_elements.pop
|
||||
else
|
||||
parse_error(_('Unexpected end tag (option) in the select phase. Ignored.'))
|
||||
parse_error("unexpected-end-tag-in-select", {"name" => "option"})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,7 +52,8 @@ module HTML5
|
|||
@tree.open_elements.pop
|
||||
# But nothing else
|
||||
else
|
||||
parse_error(_('Unexpected end tag (optgroup) in the select phase. Ignored.'))
|
||||
parse_error("unexpected-end-tag-in-select",
|
||||
{"name" => "optgroup"})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -68,7 +69,8 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagTableElements(name)
|
||||
parse_error(_("Unexpected table end tag (#{name}) in the select phase."))
|
||||
parse_error("unexpected-end-tag-in-select",
|
||||
{"name" => name})
|
||||
|
||||
if in_scope?(name, true)
|
||||
endTagSelect('select')
|
||||
|
|
|
@ -20,7 +20,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagTableCell(name, attributes)
|
||||
parse_error(_("Unexpected table cell start tag (#{name}) in the table body phase."))
|
||||
parse_error("unexpected-cell-in-table-body", {"name" => name})
|
||||
startTagTr('tr', {})
|
||||
@parser.phase.processStartTag(name, attributes)
|
||||
end
|
||||
|
@ -47,7 +47,8 @@ module HTML5
|
|||
@tree.open_elements.pop
|
||||
@parser.phase = @parser.phases[:inTable]
|
||||
else
|
||||
parse_error(_("Unexpected end tag (#{name}) in the table body phase. Ignored."))
|
||||
parse_error("unexpected-end-tag-in-table-body",
|
||||
{"name" => name})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -63,7 +64,8 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagIgnore(name)
|
||||
parse_error(_("Unexpected end tag (#{name}) in the table body phase. Ignored."))
|
||||
parse_error("unexpected-end-tag-in-table-body",
|
||||
{"name" => name})
|
||||
end
|
||||
|
||||
def endTagOther(name)
|
||||
|
@ -74,7 +76,8 @@ module HTML5
|
|||
|
||||
def clearStackToTableBodyContext
|
||||
until %w[tbody tfoot thead html].include?(name = @tree.open_elements.last.name)
|
||||
parse_error(_("Unexpected implied end tag (#{name}) in the table body phase."))
|
||||
parse_error("unexpected-implied-end-tag-in-table",
|
||||
{"name" => @tree.open_elements.last.name})
|
||||
@tree.open_elements.pop
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ module HTML5
|
|||
handle_end 'table', %w( body caption col colgroup html tbody td tfoot th thead tr ) => 'Ignore'
|
||||
|
||||
def processCharacters(data)
|
||||
parse_error(_("Unexpected non-space characters in table context caused voodoo mode."))
|
||||
parse_error("unexpected-char-implies-table-voodoo")
|
||||
# Make all the special element rearranging voodoo kick in
|
||||
@tree.insert_from_table = true
|
||||
# Process the character in the "in body" mode
|
||||
|
@ -50,13 +50,15 @@ module HTML5
|
|||
end
|
||||
|
||||
def startTagTable(name, attributes)
|
||||
parse_error(_("Unexpected start tag (table) in table phase. Implies end tag (table)."))
|
||||
parse_error("unexpected-start-tag-implies-end-tag",
|
||||
{"startName" => "table", "endName" => "table"})
|
||||
@parser.phase.processEndTag('table')
|
||||
@parser.phase.processStartTag(name, attributes) unless @parser.inner_html
|
||||
end
|
||||
|
||||
def startTagOther(name, attributes)
|
||||
parse_error(_("Unexpected start tag (#{name}) in table context caused voodoo mode."))
|
||||
parse_error("unexpected-start-tag-implies-table-voodoo",
|
||||
{"name" => name})
|
||||
# Make all the special element rearranging voodoo kick in
|
||||
@tree.insert_from_table = true
|
||||
# Process the start tag in the "in body" mode
|
||||
|
@ -69,7 +71,9 @@ module HTML5
|
|||
@tree.generateImpliedEndTags
|
||||
|
||||
unless @tree.open_elements.last.name == 'table'
|
||||
parse_error(_("Unexpected end tag (table). Expected end tag (#{@tree.open_elements.last.name})."))
|
||||
parse_error("end-tag-too-early-named",
|
||||
{"gotName" => "table",
|
||||
"expectedName" => @tree.open_elements.last.name})
|
||||
end
|
||||
|
||||
remove_open_elements_until('table')
|
||||
|
@ -83,11 +87,11 @@ module HTML5
|
|||
end
|
||||
|
||||
def endTagIgnore(name)
|
||||
parse_error(_("Unexpected end tag (#{name}). Ignored."))
|
||||
parse_error("unexpected-end-tag", {"name" => name})
|
||||
end
|
||||
|
||||
def endTagOther(name)
|
||||
parse_error(_("Unexpected end tag (#{name}) in table context caused voodoo mode."))
|
||||
parse_error("unexpected-end-tag-implies-table-voodoo", {"name" => name})
|
||||
# Make all the special element rearranging voodoo kick in
|
||||
@tree.insert_from_table = true
|
||||
# Process the end tag in the "in body" mode
|
||||
|
@ -100,7 +104,8 @@ module HTML5
|
|||
def clearStackToTableContext
|
||||
# "clear the stack back to a table context"
|
||||
until %w[table html].include?(name = @tree.open_elements.last.name)
|
||||
parse_error(_("Unexpected implied end tag (#{name}) in the table phase."))
|
||||
parse_error("unexpected-implied-end-tag-in-table",
|
||||
{"name" => @tree.open_elements.last.name})
|
||||
@tree.open_elements.pop
|
||||
end
|
||||
# When the current node is <html> it's an inner_html case
|
||||
|
|
|
@ -8,7 +8,7 @@ module HTML5
|
|||
# "quirks mode". It is expected that a future version of HTML5 will define this.
|
||||
|
||||
def process_eof
|
||||
parse_error(_('Unexpected End of file. Expected DOCTYPE.'))
|
||||
parse_error("expected-doctype-but-got-eof")
|
||||
@parser.phase = @parser.phases[:rootElement]
|
||||
@parser.phase.process_eof
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ module HTML5
|
|||
|
||||
def processDoctype(name, publicId, systemId, correct)
|
||||
if name.downcase != 'html' or publicId or systemId
|
||||
parse_error(_('Erroneous DOCTYPE.'))
|
||||
parse_error("unknown-doctype")
|
||||
end
|
||||
# XXX need to update DOCTYPE tokens
|
||||
@tree.insertDoctype(name, publicId, systemId)
|
||||
|
@ -113,22 +113,21 @@ module HTML5
|
|||
end
|
||||
|
||||
def processCharacters(data)
|
||||
parse_error(_('Unexpected non-space characters. Expected DOCTYPE.'))
|
||||
parse_error("expected-doctype-but-got-chars")
|
||||
@parser.phase = @parser.phases[:rootElement]
|
||||
@parser.phase.processCharacters(data)
|
||||
end
|
||||
|
||||
def processStartTag(name, attributes)
|
||||
parse_error(_("Unexpected start tag (#{name}). Expected DOCTYPE."))
|
||||
parse_error("expected-doctype-but-got-start-tag", {"name" => name})
|
||||
@parser.phase = @parser.phases[:rootElement]
|
||||
@parser.phase.processStartTag(name, attributes)
|
||||
end
|
||||
|
||||
def processEndTag(name)
|
||||
parse_error(_("Unexpected end tag (#{name}). Expected DOCTYPE."))
|
||||
parse_error("expected-doctype-but-got-end-tag", {"name" => name})
|
||||
@parser.phase = @parser.phases[:rootElement]
|
||||
@parser.phase.processEndTag(name)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -87,13 +87,13 @@ module HTML5
|
|||
@tree.generateImpliedEndTags
|
||||
|
||||
if @tree.open_elements.length > 2
|
||||
parse_error(_('Unexpected end of file. Missing closing tags.'))
|
||||
parse_error("expected-closing-tag-but-got-eof")
|
||||
elsif @tree.open_elements.length == 2 and @tree.open_elements[1].name != 'body'
|
||||
# This happens for framesets or something?
|
||||
parse_error(_("Unexpected end of file. Expected end tag (#{@tree.open_elements[1].name}) first."))
|
||||
parse_error("expected-closing-tag-but-got-eof")
|
||||
elsif @parser.inner_html and @tree.open_elements.length > 1
|
||||
# XXX This is not what the specification says. Not sure what to do here.
|
||||
parse_error(_('XXX inner_html EOF'))
|
||||
parse_error("eof-in-innerhtml")
|
||||
end
|
||||
# Betting ends.
|
||||
end
|
||||
|
@ -105,7 +105,7 @@ module HTML5
|
|||
end
|
||||
|
||||
def processDoctype(name, publicId, systemId, correct)
|
||||
parse_error(_('Unexpected DOCTYPE. Ignored.'))
|
||||
parse_error("unexpected-doctype")
|
||||
end
|
||||
|
||||
def processSpaceCharacters(data)
|
||||
|
@ -118,7 +118,7 @@ module HTML5
|
|||
|
||||
def startTagHtml(name, attributes)
|
||||
if @parser.first_start_tag == false and name == 'html'
|
||||
parse_error(_('html needs to be the first start tag.'))
|
||||
parse_error("non-html-root")
|
||||
end
|
||||
# XXX Need a check here to see if the first start tag token emitted is
|
||||
# this token... If it's not, invoke parse_error.
|
||||
|
@ -134,10 +134,6 @@ module HTML5
|
|||
send self.class.end_tag_handlers[name], name
|
||||
end
|
||||
|
||||
def _(string)
|
||||
string
|
||||
end
|
||||
|
||||
def assert(value)
|
||||
throw AssertionError.new unless value
|
||||
end
|
||||
|
|
|
@ -15,19 +15,19 @@ module HTML5
|
|||
end
|
||||
|
||||
def processCharacters(data)
|
||||
parse_error(_('Unexpected non-space characters. Expected end of file.'))
|
||||
parse_error("expected-eof-but-got-char")
|
||||
@parser.phase = @parser.last_phase
|
||||
@parser.phase.processCharacters(data)
|
||||
end
|
||||
|
||||
def processStartTag(name, attributes)
|
||||
parse_error(_('Unexpected start tag (#{name}). Expected end of file.'))
|
||||
parse_error("expected-eof-but-got-start-tag", {"name" => name})
|
||||
@parser.phase = @parser.last_phase
|
||||
@parser.phase.processStartTag(name, attributes)
|
||||
end
|
||||
|
||||
def processEndTag(name)
|
||||
parse_error(_('Unexpected end tag (#{name}). Expected end of file.'))
|
||||
parse_error("expected-eof-but-got-end-tag", {"name" => name})
|
||||
@parser.phase = @parser.last_phase
|
||||
@parser.phase.processEndTag(name)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue