p-hatan/ mirror

pub repository

mirror.p-hatan.ir

html5lib

0.0.2

library for working with HTML documents

This package is discontinued upstream.

Download archive

Readme

html5lib in Pure Dart

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 or the server.

Installation

Add this to your pubspec.yaml (or create it):

dependencies:
  html5lib:
    git: https://github.com/dart-lang/html5lib.git

Then run the Pub Package Manager (comes with the Dart SDK):

pub install

Usage

Parsing HTML is easy!

#import('package:html5lib/html5parser.dart', prefix: 'html5parser');

main() {
  var document = html5parser.parse(
    '<body>Hello world! <a href="www.html5rocks.com">HTML5 rocks!');
  print(document.outerHTML);
}

You can pass a String, RandomAccessFile, or list of bytes to parse. There's also parseFragment for parsing a document fragment, and HTMLParser if you want more low level control. Finally, you can get the simple DOM tree types like this:

#import('package:html5lib/treebuilders/simpletree.dart');

Updating

You can upgrade the library with:

pub update

Disclaimer: the APIs are not finished. Updating may break your code. If that happens, you can check the commit log, to figure out what the change was.

Implementation Status

Right now the tokenizer, html5parser, and simpletree are working.

These files from the html5lib directory still need to be ported:

  • ihatexml.py
  • sanitizer.py
  • filters/*
  • serializer/*
  • most of treebuilders/*
  • treewalkers/*
  • most of tests

Running Tests

All tests should be passing.

# Make sure dependencies are installed
pub install

# Run command line tests
#export DART_SDK=path/to/dart/sdk
tests/run.sh
Changelog

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add html5lib
pubspec.yaml
name: html5lib
description: library for working with HTML documents
version: 0.0.2
dependencies:
  unittest: { sdk: unittest }
  args: { sdk: args }
  logging: { sdk: logging }

Version history

VersionPublishedArchiveSHA-256
0.0.12012-08-30T23:58:09.709670ZDownload332a954cb7718c63e8ce2a810ae90dc0bc740969a69ade87c95b9eeceb081877
0.0.22012-09-07T00:36:25.385610ZDownload5085d80e3e3b84873e7004d7333a446564392b4a4eb0b68a2d745d778ef18ab4
0.0.32012-09-11T23:53:06.690110ZDownloade160e7561dedc941af778f71bbf43dada80988fb8985cc4e7f84e24b97fa7f34
0.0.42012-09-13T21:13:46.890740ZDownloadf0da63b4693c899fc4c04fd59ff88d2102c78a4877b92e8aecf1da7a9a90aa28
0.0.52012-09-21T02:59:55.686090ZDownloadf78d27832824fb95b4c7c050d8b3e695615f646a29085997970b351fed4eaad5
0.0.62012-09-22T00:22:37.986770ZDownloadd78200ff755c22dc81b81a79c57e94e5e06f59c514dabf677935c6cd77c957b3
0.0.72012-09-25T01:21:29.992190ZDownload4598b212036266dd0cd1c8b690f9015ec9ba10193cdd443bec093159e2ea6741
0.0.82012-09-28T23:11:30.434750ZDownload815f559f0dde93d37ea670d39a7f216316684f4ca999ee6cacaa0e847f77de14
0.0.92012-09-28T23:13:21.507890ZDownload9fda741211779ebc62941252b69c35c83ae6a4574671434f0da046c5f83bb567
0.0.102012-10-01T17:46:57.918180ZDownload5868ee528b2d2890a8958f24c653fbb74a79dd3f7f0606fde4bce534967b4cf2
0.0.112012-10-02T20:30:59.791160ZDownload7317bdb05df3fdad791edc88a45aa10f865fca8e0af9072a1e575161a06b15fe
0.0.122012-10-04T18:47:41.693740ZDownload70f3912c614c3a44915027363824204f3183ba2e21d20383c31fa7dfdf6f8c23
0.0.132012-10-19T18:50:14.824980ZDownload2660d071fd16c3d56ad4ef5a7330b09fb81600d9d0d67517b075c0f95244863d
0.0.142012-10-22T21:00:00.492630ZDownload171aeb369853e6d8e19919f736124487a618036ce1701cbe658c27c4392a1d32
0.0.152012-10-23T17:59:00.230910ZDownloadaeb945d61ca9d505212a4a64cb8776cb5ca054856077a79f96ca3d5b770fd717
0.0.162012-10-24T17:57:26.656800ZDownloadfa9653c987000b681b3382c8ff7d4f15940884def4085d6cd7b75b6d46732627
0.0.172012-10-25T22:50:49.950670ZDownloade8602adb3a8b6c8abcce47ca0d83232252a7bb1ff9c060a4cbac3909dcc8f41e
0.0.182012-10-26T18:59:49.770840ZDownloadf3f5f9395a93240a85ae7d30c0fe0b7eb88b78f680ee9c85f9a2e81b427ec30d
0.0.192012-10-29T20:31:27.767490ZDownloadd083bd6a086358889a484f8d077685a1f0d5bdde3f54a618a5cc0e4bb5714d99
0.2.02012-11-16T18:35:13.262690ZDownload70017f90f74e5c682e577b73ee3e5bb3af9e6d067ce79e8470c467936b31c0dd
0.2.12012-11-26T22:24:54.270090ZDownload29f2504637b549f843263bf71fcfe4c134c8847a5505092434909bda140d9972
0.2.1+12012-11-30T21:37:51.439060ZDownloadb949578d9a93ce23149662bf59caecc2eb6613affd6e6d7dd3dd64943848663a
0.2.22012-12-13T17:40:04.570260ZDownload619affb785cffc7b5ee8844702f45eb09268545a3075ec3b4ef25593f3db029c
0.2.2+12013-01-04T21:58:30.661850ZDownload1a262cee196679d2ea927a56744594dd2cb8b4723768aa32cea26cac936fd16b
0.3.02013-01-22T21:34:34.736660ZDownloade3b013cdb306fb551e53468b7da1a9ccc6475f9a9c96f897fb9e1fb90200c4b9
0.3.0+12013-01-23T05:03:21.015690ZDownloade4542e027a7b09bc4b52b28d516a6a969f5ffbaf808a415c080ae3918c197d21
0.3.12013-01-28T18:23:35.653720ZDownloadc3b612ccad1961eb812c4a1323f33d8408611c0544331055d9317c8e5b8baea7
0.3.1+12013-01-30T20:51:08.705840ZDownload39b3aefe98fef8d2562d59c35cc8a22b8810fd005cc3a3cf62ce0ed6c78c0056
0.3.1+22013-01-31T14:58:51.145660ZDownload4f1983c682b881a6efab511019e28ed2dfc8bf9e61e0e2071a1f0e1278fa4862
0.3.22013-02-06T03:42:55.541510ZDownload20e4cbc12cc1373929137f4e689f3f61d4fca2fe5900ddc0c5adfad80d44c5ec
0.3.2+12013-02-11T18:38:54.839550ZDownload75c8ab9cdddd4105deb0a857c81e673af5e6120225eb8f4ac964da1a1bdb497e
0.3.32013-02-19T16:30:22.106180ZDownloadec732144b0094add384224e891d1c8ca0be77d1b703ee0294ebca16065a49cc2
0.3.3+12013-02-27T00:04:47.885270ZDownloadb5d05aa579fc0e1fa495d540c028180590635b0271cc6c0aa024dd5ac3bfae06
0.3.3+22013-02-27T01:36:04.647710ZDownload319f3e7bb983973a84e8835ec80f6ececeb60485795cd2c11f17e3523aa62e4a
0.4.02013-03-09T01:01:05.403070ZDownload51eba049e38d8beb84e847c22f918b4b3ce9c797bdc39e612a20c15f86ce3cba
0.4.12013-03-16T00:41:47.418540ZDownload7a812108bd164c69bab13ce605c4e32cb3aca53fb7e7af5e612d8e769f1b6bac
0.4.22013-04-13T00:43:05.854650ZDownload55d81f7e18147c7ee455a568b40602d3d9878c525de949f4e8def89d99b5efca
0.4.32013-04-16T16:02:54.400570ZDownload23c7a5e50085df5707aeb2fbed5f87d7b71af49a37e90fc969bed91d61935fda
0.4.42013-07-19T20:34:40.993290ZDownloadf165b3f692ef079fe61a3e45c3c961f055570594703677222f1f75cf6250b630
0.6.192013-08-19T16:12:12.229740ZDownload54e7904359744f2e733eeb713b7104a0d819b5c35804385d9326838f4f051ece
0.6.20+12013-08-22T18:20:52.297960ZDownload5431df15ee4b44158e2522814ccbf152c1697933a469540fe4d1786f74513616
0.6.21+32013-08-26T17:44:32.575880ZDownload1300732e1e948ab414c8f2b6f23789de1b8088ccc62dac6ec024b3955eee5ffd
0.7.02013-08-28T19:30:25.295900ZDownloadab1b919d1df00137356d0c353f8437084e4de230cd662b89e6886a9545e01fb5
0.7.12013-09-03T15:56:50.570970ZDownloadc742ed5b6b80fb0b8a8362a0b2464b8234e3f8d694be6ba975d6173f34a596f6
0.7.22013-09-06T15:52:55.157ZDownload5248c81237c1b81da1e0dd0d390d91e06e7cba4431920919baae8b746e6a26b2
0.7.2+12013-09-08T15:49:03.334340ZDownloadb0bc3fa0e4612703bafc80b675a4af11edf6b2e942cb5f62312e0f0598520ca2
0.7.3+12013-09-16T15:45:57.520330ZDownload0fa768e1f7fdd7198246df2d093ea8c48c7407d210a138639aec3a0cee5d45db
0.7.42013-09-18T03:05:30.409110ZDownload4b003dd2a130c656eee0efc4b733de7fe15b0faeb8dee841035dd77d05ccc350
0.7.52013-09-21T00:44:12.563400ZDownloaddfe8141bab9629e84782b9cc2566ff4e79658a103cf3060d4d7581b5d9788e01
0.7.62013-09-27T14:59:19.356600ZDownload63e122e0602cddb15c8fccae6b6280fdcf1c04efa969d80bf3b22328332f6c47
0.7.6+42013-10-01T23:50:32.870250ZDownload7c2d986c1586c68d97a21212aa4bbcf02f7e7536fbdb00e2412f83a2b47deb36
0.8.02013-10-03T16:30:08.610040ZDownload60c3b26e88f9058f9975945677ef414b7ac2222cfaedbd31c69dcf6b6e60d710
0.8.12013-10-04T21:55:56.218840ZDownload98031b09db1c8cc35dfa738c651b38abc7a984e4d243da8184d681878ee6ef63
0.8.22013-10-14T21:46:21.291960ZDownload251fc644dcdde71f955b3b4bcc8325f544d3f914c4b8a0c95851ca2ad7f7d043
0.8.32013-10-17T16:02:14.237350ZDownload16878d0d78490a8c33fde95668a965414667473b1fc738b8fb379f159cd9c377
0.8.42013-10-19T21:10:36.244920ZDownloadfa5877ed6fd7da16856d9324335897cafd10a950d30da12e69fc02c683a22308
0.8.52013-10-21T15:53:44.939680ZDownload22e367b992fb7d7c4d9f3996e11007a6d10a0a2a2925fb6d53edee2b51031599
0.8.62013-10-24T08:22:35.579730ZDownload21715ee55db201a28bd4d36d12c075fa0922bed468ff264b6e40923795ad1359
0.8.72013-10-28T14:35:09.184600ZDownloada7d2ae540bdf40e363cec0123970b2862798e1d4b6aab68c675c299a93c7eb4c
0.8.82013-10-30T03:30:53.396850ZDownloada2525c7415940b2da754ec756de295a84bf310f68cf3fd5841723eb41ea209cc
0.8.92013-10-31T15:17:29.047800ZDownload679cbb7be689015ba5d5ed2cb082a2f7f377a890c3f0f3336e833a05ba61500e
0.8.102013-11-01T19:24:37.287430ZDownloadd023af4fcf5a8d159aeca06138854402aea5a94f4a767c2720dd73b9c1dd9025
0.8.10+32013-11-04T16:51:17.825830ZDownload30d76833706274a23a07c2756c0a6ea38af47cfa70bbaebe47b26c5acabf3c3c
0.8.10+42013-11-05T16:07:26.653020ZDownloadf7594ad646acc18cd7994d15b4f4b932e48e4d8ebcea7f23cbeb65d6370fabd0
0.9.02013-11-06T19:35:10.696170ZDownload7d34cae770b009ac72917ddfc9400baaab28040b92d477e1d0e0442bb0eb48a1
0.9.12013-11-22T23:26:25.251680ZDownload68ed248514709b8064cf6b6b55c528b61cd6a4440148ad1ed641ec90aefc0b48
0.9.22014-02-28T23:12:09.822570ZDownload8db42602b0addad15536a815b378c89d49b7cc159f1a53394534880d2c911a01
0.10.02014-04-04T20:49:49.752900ZDownload0d6890354f107b187ead957c664d11465c9d5fd94a5f68af9356afe3a461abbd
0.11.0-dev2014-05-21T17:22:05.655230ZDownload86e61e3dfc1ec4356d1546991b5c32af94d7145e99024da401822ba9fbebcfda
0.11.02014-05-23T22:00:21.890950ZDownload607e7781c9064f68f15eb7774b07a689950b5bab29882abd713e2ed3adc7b366
0.11.0+12014-05-28T00:44:19.580810ZDownload82c57520a33ae38cd8dce16d38122b34e8238854b214af72678d12e483d1cc5b
0.11.0+22014-07-30T00:14:50.703550ZDownload73380a8e28a8e8162f76bc6649ec97900c9d0612718a2fe64bf94bc1db83d86b
0.12.02014-07-30T21:38:31.970110ZDownload8b8b46494fe79c49865895ba72cb48336320ced96e6c8167b573da5a1f44e0e6
0.12.0+12015-03-19T21:01:17.077ZDownload28d7788d24e6c3237bfc4afd522c5ed62d99321029792112f1722827715bb281
0.12.0+22015-03-20T15:50:29.484230ZDownload1f8d724dd7d6cad2bf6498cfd203cd1f83ffca0e9e620b4ce9d1124b18f34d3c
0.12.12015-03-20T16:15:04.448920ZDownload91fd43d86a25b3e09dbe51dade450be0d9cdcd411d5b507c2aba04854d28f9b0

Dependencies

args { "sdk": "args" }

logging { "sdk": "logging" }

unittest { "sdk": "unittest" }