OLD | NEW |
1 /// This library has a parser for HTML5 documents, that lets you parse HTML | 1 /// This library has a parser for HTML5 documents, that lets you parse HTML |
2 /// easily from a script or server side application: | 2 /// easily from a script or server side application: |
3 /// | 3 /// |
4 /// import 'package:html/parser.dart' show parse; | 4 /// import 'package:html/parser.dart' show parse; |
5 /// import 'package:html/dom.dart'; | 5 /// import 'package:html/dom.dart'; |
6 /// main() { | 6 /// main() { |
7 /// var document = parse( | 7 /// var document = parse( |
8 /// '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!'); | 8 /// '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!'); |
9 /// print(document.outerHtml); | 9 /// print(document.outerHtml); |
10 /// } | 10 /// } |
(...skipping 3377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3388 }; | 3388 }; |
3389 | 3389 |
3390 var replace = replacements[token.name]; | 3390 var replace = replacements[token.name]; |
3391 if (replace != null) { | 3391 if (replace != null) { |
3392 token.name = replace; | 3392 token.name = replace; |
3393 } | 3393 } |
3394 } | 3394 } |
3395 | 3395 |
3396 Token processCharacters(CharactersToken token) { | 3396 Token processCharacters(CharactersToken token) { |
3397 if (token.data == "\u0000") { | 3397 if (token.data == "\u0000") { |
3398 token.data = "\uFFFD"; | 3398 token.replaceData("\uFFFD"); |
3399 } else if (parser.framesetOK && !allWhitespace(token.data)) { | 3399 } else if (parser.framesetOK && !allWhitespace(token.data)) { |
3400 parser.framesetOK = false; | 3400 parser.framesetOK = false; |
3401 } | 3401 } |
3402 return super.processCharacters(token); | 3402 return super.processCharacters(token); |
3403 } | 3403 } |
3404 | 3404 |
3405 Token processStartTag(StartTagToken token) { | 3405 Token processStartTag(StartTagToken token) { |
3406 var currentNode = tree.openElements.last; | 3406 var currentNode = tree.openElements.last; |
3407 if (breakoutElements.contains(token.name) || | 3407 if (breakoutElements.contains(token.name) || |
3408 (token.name == "font" && | 3408 (token.name == "font" && |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3782 return span.sourceUrl == null ? 'ParserError on $res' : 'On $res'; | 3782 return span.sourceUrl == null ? 'ParserError on $res' : 'On $res'; |
3783 } | 3783 } |
3784 } | 3784 } |
3785 | 3785 |
3786 /// Convenience function to get the pair of namespace and localName. | 3786 /// Convenience function to get the pair of namespace and localName. |
3787 Pair<String, String> getElementNameTuple(Element e) { | 3787 Pair<String, String> getElementNameTuple(Element e) { |
3788 var ns = e.namespaceUri; | 3788 var ns = e.namespaceUri; |
3789 if (ns == null) ns = Namespaces.html; | 3789 if (ns == null) ns = Namespaces.html; |
3790 return new Pair(ns, e.localName); | 3790 return new Pair(ns, e.localName); |
3791 } | 3791 } |
OLD | NEW |