", token.asTagToken.tagName];
+ } else {
+ break;
+ }
+ return;
+ default:
+ break;
+ }
+
+ [self HTMLInsertionModeInTable:token];
}
- (void)HTMLInsertionModeInCell:(HTMLToken *)token
{
+ switch (token.type) {
+ case HTMLTokenTypeEndTag:
+ if ([token.asTagToken.tagName isEqualToAny:@"td", @"th", nil]) {
+ if (![_stackOfOpenElements hasElementInTableScopeWithTagName:token.asTagToken.tagName]) {
+ [self emitParseError:@"Unexpected Tag Token (%@) for element in | ", token.asTagToken.tagName];
+ return;
+ } else {
+ [self generateImpliedEndTagsExceptForElement:nil];
+ if (![self.currentNode.tagName isEqualToString:@"colgroup"]) {
+ [self emitParseError:@"Unexpected nested (%@) element in | ", token.asTagToken.tagName];
+ }
+ [_stackOfOpenElements popElementsUntilElementPoppedWithTagName:token.asTagToken.tagName];
+ [self clearListOfActiveFormattingElementsUpToLastMarker];
+ [self switchInsertionMode:HTMLInsertionModeInRow];
+ }
+ } else if ([token.asTagToken.tagName isEqualToAny:@"body", @"caption", @"col", @"colgroup",
+ @"html", nil]) {
+ [self emitParseError:@"Unexpected End Tag Token (%@) in | ", token.asTagToken.tagName];
+ } else if ([token.asTagToken.tagName isEqualToAny:@"table", @"tbody", @"tfoot", @"thhead", @"tr", nil]) {
+ if (![_stackOfOpenElements hasElementInTableScopeWithTagName:token.asTagToken.tagName]) {
+ [self emitParseError:@"Unexpected End Tag Token (%@) for element in | ", token.asTagToken.tagName];
+ return;
+ } else {
+ [self closeTheCell];
+ }
+ } else {
+ break;
+ }
+ return;
+ case HTMLTokenTypeStartTag:
+ if ([token.asTagToken.tagName isEqualToAny:@"caption", @"col", @"colgroup", @"tbody",
+ @"td", @"tfoot", @"th", @"thead", @"tr", nil]) {
+ if (![_stackOfOpenElements hasElementInTableScopeWithTagName:@"td"] &&
+ ![_stackOfOpenElements hasElementInTableScopeWithTagName:@"th"]) {
+ [self emitParseError:@"Unexpected Start Tag Token (%@) for element in | ", token.asTagToken.tagName];
+ return;
+ } else {
+ [self closeTheCell];
+ }
+ } else {
+ break;
+ }
+ return;
+ default:
+ break;
+ }
+ [self HTMLInsertionModeInBody:token];
}
- (void)HTMLInsertionModeInSelect:(HTMLToken *)token
{
+ switch (token.type) {
+ case HTMLTokenTypeCharacter:
+ {
+ NSMutableString *charactes = [token.asCharacterToken.characters mutableCopy];
+ NSUInteger nullCount = [charactes replaceOccurrencesOfString:@"\0"
+ withString:@""
+ options:NSLiteralSearch
+ range:NSMakeRange(0, charactes.length)];
+ for (int i = 0; i < nullCount; i++) {
+ [self emitParseError:@"Unexpected Character (0x0000) in |