diff --git a/HTMLKit/HTMLParser.m b/HTMLKit/HTMLParser.m index 6da0509..8558282 100644 --- a/HTMLKit/HTMLParser.m +++ b/HTMLKit/HTMLParser.m @@ -519,7 +519,7 @@ - (void)generateImpliedEndTagsExceptForElement:(NSString *)tagName { - while ([self.currentNode.tagName isEqualToAny:@"dd", @"dt", @"li", @"option", @"optgroup", @"p", @"rp", @"rt", nil] && + while ([self.currentNode.tagName isEqualToAny:@"dd", @"dt", @"li", @"option", @"optgroup", @"p", @"rb", @"rp", @"rt", @"rtc", nil] && ![self.currentNode.tagName isEqualToString:tagName]) { [_stackOfOpenElements popCurrentNode]; } @@ -528,7 +528,7 @@ - (void)generateAllImpliedEndTagsThoroughly { while ([self.currentNode.tagName isEqualToAny:@"caption", @"colgroup", @"dd", @"dt", @"li", @"option", @"optgroup", @"p", - @"rp", @"rt", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", nil]) { + @"rb", @"rp", @"rt", @"rtc", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", nil]) { [_stackOfOpenElements popCurrentNode]; } } @@ -1158,8 +1158,8 @@ [self HTMLInsertionModeInTemplate:token]; } else { for (HTMLElement *node in _stackOfOpenElements) { - if ([node.tagName isEqualToAny:@"dd", @"dt", @"li", @"optgroup", @"option", @"p", @"rp" - @"rt", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", @"body", @"html", nil]) { + if ([node.tagName isEqualToAny:@"dd", @"dt", @"li", @"optgroup", @"option", @"p", @"rb", @"rp", + @"rt", @"rtc", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", @"body", @"html", nil]) { [self emitParseError:@"EOF reached with unclosed element <%@> in ", node.tagName]; break; } @@ -1462,7 +1462,7 @@ } [self reconstructActiveFormattingElements]; [self insertElementForToken:token]; - } else if ([tagName isEqualToAny:@"rp", @"rt", nil]) { + } else if ([tagName isEqualToAny:@"rb", @"rtc", nil]) { if ([_stackOfOpenElements hasElementInScopeWithTagName:@"ruby"]) { [self generateImpliedEndTagsExceptForElement:nil]; if (![self.currentNode.tagName isEqualToString:@"ruby"]) { @@ -1470,6 +1470,15 @@ } } [self insertElementForToken:token]; + } else if ([tagName isEqualToAny:@"rp", @"rt", nil]) { + if ([_stackOfOpenElements hasElementInScopeWithTagName:@"ruby"]) { + [self generateImpliedEndTagsExceptForElement:@"rtc"]; + if (![self.currentNode.tagName isEqualToString:@"rtc"] && + ![self.currentNode.tagName isEqualToString:@"ruby"]) { + [self emitParseError:@"Unexpected start tag <%@> outside of or in ", tagName]; + } + } + [self insertElementForToken:token]; } else if ([tagName isEqualToString:@"math"]) { [self reconstructActiveFormattingElements]; AdjustMathMLAttributes(token); @@ -1507,8 +1516,8 @@ [self emitParseError:@"Unexpected end tag without body element in scope in "]; } for (HTMLElement *node in _stackOfOpenElements) { - if ([node.tagName isEqualToAny:@"dd", @"dt", @"li", @"optgroup", @"option", @"p", @"rp" - @"rt", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", @"body", @"html", nil]) { + if ([node.tagName isEqualToAny:@"dd", @"dt", @"li", @"optgroup", @"option", @"p", @"rb", @"rp", @"rt", + @"rtc", @"tbody", @"td", @"tfoot", @"th", @"thead", @"tr", @"body", @"html", nil]) { [self emitParseError:@"Misnested end tag with open element <%@> in ", tagName, node.tagName]; break; } diff --git a/HTMLKitTests/HTML5LibTreeConstructionTest.m b/HTMLKitTests/HTML5LibTreeConstructionTest.m index a10dc22..659a094 100644 --- a/HTMLKitTests/HTML5LibTreeConstructionTest.m +++ b/HTMLKitTests/HTML5LibTreeConstructionTest.m @@ -33,12 +33,6 @@ static NSString * const TreeConstruction = @"tree-construction"; continue; } - if ([testFile hasPrefix:@"ruby"]) { - // and friends are not yet completely supported - // https://www.w3.org/Bugs/Public/show_bug.cgi?id=26189 - continue; - } - NSString *testFilePath = [path stringByAppendingPathComponent:testFile]; NSArray *tests = [HTML5LibTreeConstructionTest loadTestsWithFileAtPath:testFilePath]; [testsMap setObject:tests forKey:testFile]; @@ -74,12 +68,6 @@ static NSString * const TreeConstruction = @"tree-construction"; HTML5LibTreeConstructionTest *test = [HTML5LibTreeConstructionTest new]; test.testFile = filePath.lastPathComponent; - if ([rawTest rangeOfString:@"ruby"].location != NSNotFound) { - // and friends are not yet completely supported - // https://www.w3.org/Bugs/Public/show_bug.cgi?id=26189 - continue; - } - if ([rawTest rangeOfString:@"#script-off"].location != NSNotFound) { // Ignore tests for "scripting flag disabled" case continue;