Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /** | 1 /** |
| 2 * This library has a parser for HTML5 documents, that lets you parse HTML | 2 * This library has a parser for HTML5 documents, that lets you parse HTML |
| 3 * easily from a script or server side application: | 3 * easily from a script or server side application: |
| 4 * | 4 * |
| 5 * import 'package:html5lib/parser.dart' show parse; | 5 * import 'package:html5lib/parser.dart' show parse; |
| 6 * import 'package:html5lib/dom.dart'; | 6 * import 'package:html5lib/dom.dart'; |
| 7 * main() { | 7 * main() { |
| 8 * var document = parse( | 8 * var document = parse( |
| 9 * '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!'); | 9 * '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!'); |
| 10 * print(document.outerHtml); | 10 * print(document.outerHtml); |
| (...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1676 } else if (tree.openElements.last.tagName != "body") { | 1676 } else if (tree.openElements.last.tagName != "body") { |
| 1677 for (Node node in slice(tree.openElements, 2)) { | 1677 for (Node node in slice(tree.openElements, 2)) { |
| 1678 switch (node.tagName) { | 1678 switch (node.tagName) { |
| 1679 case "dd": case "dt": case "li": case "optgroup": case "option": | 1679 case "dd": case "dt": case "li": case "optgroup": case "option": |
| 1680 case "p": case "rp": case "rt": case "tbody": case "td": case "tfoot": | 1680 case "p": case "rp": case "rt": case "tbody": case "td": case "tfoot": |
| 1681 case "th": case "thead": case "tr": case "body": case "html": | 1681 case "th": case "thead": case "tr": case "body": case "html": |
| 1682 continue; | 1682 continue; |
| 1683 } | 1683 } |
| 1684 // Not sure this is the correct name for the parse error | 1684 // Not sure this is the correct name for the parse error |
| 1685 parser.parseError(token.span, "expected-one-end-tag-but-got-another", | 1685 parser.parseError(token.span, "expected-one-end-tag-but-got-another", |
| 1686 {"expectedName": "body", "gotName": node.tagName}); | 1686 {"gotName": "body", "expectedName": node.tagName}); |
|
Jennifer Messerly
2014/02/21 23:22:18
upstream this fix?
https://github.com/html5lib/htm
Siggi Cherem (dart-lang)
2014/02/21 23:35:29
All set:
https://github.com/html5lib/html5lib-pyth
| |
| 1687 break; | 1687 break; |
| 1688 } | 1688 } |
| 1689 } | 1689 } |
| 1690 parser.phase = parser._afterBodyPhase; | 1690 parser.phase = parser._afterBodyPhase; |
| 1691 } | 1691 } |
| 1692 | 1692 |
| 1693 Token endTagHtml(EndTagToken token) { | 1693 Token endTagHtml(EndTagToken token) { |
| 1694 //We repeat the test for the body end tag token being ignored here | 1694 //We repeat the test for the body end tag token being ignored here |
| 1695 if (tree.elementInScope("body")) { | 1695 if (tree.elementInScope("body")) { |
| 1696 endTagBody(new EndTagToken("body")); | 1696 endTagBody(new EndTagToken("body")); |
| (...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3370 * [span.getLocationMessage] will not show any source url information, but | 3370 * [span.getLocationMessage] will not show any source url information, but |
| 3371 * [toString] will include 'ParserError:' as a prefix. | 3371 * [toString] will include 'ParserError:' as a prefix. |
| 3372 */ | 3372 */ |
| 3373 String get message => formatStr(errorMessages[errorCode], data); | 3373 String get message => formatStr(errorMessages[errorCode], data); |
| 3374 | 3374 |
| 3375 String toString() { | 3375 String toString() { |
| 3376 var res = span.getLocationMessage(message); | 3376 var res = span.getLocationMessage(message); |
| 3377 return span.sourceUrl == null ? 'ParserError$res' : res; | 3377 return span.sourceUrl == null ? 'ParserError$res' : res; |
| 3378 } | 3378 } |
| 3379 } | 3379 } |
| OLD | NEW |