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:html5lib/parser.dart' show parse; | 4 /// import 'package:html5lib/parser.dart' show parse; |
5 /// import 'package:html5lib/dom.dart'; | 5 /// import 'package:html5lib/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 3336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3347 /// Gets the human readable error message for this error. Use | 3347 /// Gets the human readable error message for this error. Use |
3348 /// [span.getLocationMessage] or [toString] to get a message including span | 3348 /// [span.getLocationMessage] or [toString] to get a message including span |
3349 /// information. If there is a file associated with the span, both | 3349 /// information. If there is a file associated with the span, both |
3350 /// [span.getLocationMessage] and [toString] are equivalent. Otherwise, | 3350 /// [span.getLocationMessage] and [toString] are equivalent. Otherwise, |
3351 /// [span.getLocationMessage] will not show any source url information, but | 3351 /// [span.getLocationMessage] will not show any source url information, but |
3352 /// [toString] will include 'ParserError:' as a prefix. | 3352 /// [toString] will include 'ParserError:' as a prefix. |
3353 String get message => formatStr(errorMessages[errorCode], data); | 3353 String get message => formatStr(errorMessages[errorCode], data); |
3354 | 3354 |
3355 String toString() { | 3355 String toString() { |
3356 var res = span.getLocationMessage(message); | 3356 var res = span.getLocationMessage(message); |
3357 return span.sourceUrl == null ? 'ParserError$res' : res; | 3357 return span.sourceUrl == null ? 'ParserError on $res' : 'On $res'; |
3358 } | 3358 } |
3359 } | 3359 } |
3360 | 3360 |
3361 | 3361 |
3362 /// Convenience function to get the pair of namespace and localName. | 3362 /// Convenience function to get the pair of namespace and localName. |
3363 Pair<String, String> getElementNameTuple(Element e) { | 3363 Pair<String, String> getElementNameTuple(Element e) { |
3364 var ns = e.namespaceUri; | 3364 var ns = e.namespaceUri; |
3365 if (ns == null) ns = Namespaces.html; | 3365 if (ns == null) ns = Namespaces.html; |
3366 return new Pair(ns, e.localName); | 3366 return new Pair(ns, e.localName); |
3367 } | 3367 } |
OLD | NEW |