| OLD | NEW |
| (Empty) |
| 1 html5lib in Pure Dart | |
| 2 ===================== | |
| 3 | |
| 4 This is a pure [Dart][dart] [html5 parser][html5parse]. It's a port of | |
| 5 [html5lib](http://code.google.com/p/html5lib/) from Python. Since it's 100% | |
| 6 Dart you can use it safely from a script or server side app. | |
| 7 | |
| 8 Eventually the parse tree API will be compatible with [dart:html][d_html], so | |
| 9 the same code will work on the client and the server. | |
| 10 | |
| 11 Installation | |
| 12 ------------ | |
| 13 | |
| 14 Add this to your `pubspec.yaml` (or create it): | |
| 15 ```yaml | |
| 16 dependencies: | |
| 17 html5lib: any | |
| 18 ``` | |
| 19 Then run the [Pub Package Manager][pub] (comes with the Dart SDK): | |
| 20 | |
| 21 pub install | |
| 22 | |
| 23 Usage | |
| 24 ----- | |
| 25 | |
| 26 Parsing HTML is easy! | |
| 27 ```dart | |
| 28 import 'package:html5lib/parser.dart' show parse; | |
| 29 import 'package:html5lib/dom.dart'; | |
| 30 | |
| 31 main() { | |
| 32 var document = parse( | |
| 33 '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!'); | |
| 34 print(document.outerHtml); | |
| 35 } | |
| 36 ``` | |
| 37 | |
| 38 You can pass a String or list of bytes to `parse`. | |
| 39 There's also `parseFragment` for parsing a document fragment, and `HtmlParser` | |
| 40 if you want more low level control. | |
| 41 | |
| 42 Running Tests | |
| 43 ------------- | |
| 44 | |
| 45 ```bash | |
| 46 # From Dart SVN checkout | |
| 47 ./tools/build.py -m release | |
| 48 ./tools/test.py -m release html5lib | |
| 49 ./tools/test.py -m release -r drt html5lib | |
| 50 ``` | |
| 51 | |
| 52 [dart]: http://www.dartlang.org/ | |
| 53 [html5parse]: http://dev.w3.org/html5/spec/parsing.html | |
| 54 [d_html]: http://api.dartlang.org/docs/continuous/dart_html.html | |
| 55 [files]: http://html5lib.googlecode.com/hg/python/html5lib/ | |
| 56 [pub]: http://www.dartlang.org/docs/pub-package-manager/ | |
| OLD | NEW |