commit | 93f119d409f907f892caa27b59beaeb4cbb0ce7c | [log] [tgz] |
---|---|---|
author | John Messerly <jmesserly@google.com> | Mon Mar 09 14:01:49 2015 -0700 |
committer | John Messerly <jmesserly@google.com> | Mon Mar 09 14:01:49 2015 -0700 |
tree | b2c22a49b2d33a886c6586376c7b811c3967a1dd | |
parent | fa3b49558efac1d7663decc7f862836e7944a8bc [diff] | |
parent | 1e91815316659c0109a78faa51b9c21c66b82a18 [diff] |
Merge pull request #11 from dart-lang/sethladd-patch-2 Just making things extra clear :)
This is a pure Dart html5 parser. It‘s a port of html5lib from Python. Since it’s 100% Dart you can use it safely from a script or server side app.
Eventually the parse tree API will be compatible with dart:html, so the same code will work on the client and the server.
(Formally known as html5lib.)
Add this to your pubspec.yaml
(or create it):
dependencies: html: any
Then run the Pub Package Manager (comes with the Dart SDK):
pub install
Parsing HTML is easy!
import 'package:html/parser.dart' show parse; import 'package:html/dom.dart'; main() { var document = parse( '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!'); print(document.outerHtml); }
You can pass a String or list of bytes to parse
. There's also parseFragment
for parsing a document fragment, and HtmlParser
if you want more low level control.
./test/run.sh