html_parser 0.6.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 57

html_parser

Build Status Pub

A fast and forgiving HTML parser for Dart. Loosely based on htmlparser2.

This package is in development as an experiment to replace the transpiled HTML parser from angular_2. It is not meant to be a full DOM parser, or to emulate behavior of the browser - for that see package:html.

Goals are speed, ease of use, and great error messages.

Usage

import 'package:html_parser/html_parser.dart';

void main() {
  var fragment = parseHtml('<div>Hello World</div>');

  // Prints: '<div>Hello World</div>'
  print(nodeToString(fragment));
}

Limitations

Some things missing from making this a package ready to use for all:

See issues for more details and to contribute!

Changelog

0.6.0

  • Exported Attribute and Comment nodes as part of the public API
  • Exported HtmlVisitor and PrinterHtmlVisitor
  • Added .fromToken(s) APIs for some of the Element ASTs (internal use)

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  html_parser: "^0.6.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:html_parser/html_parser.dart';
        
Version Uploaded Documentation Archive
0.6.0 Oct 10, 2016 Go to the documentation of html_parser 0.6.0 Download html_parser 0.6.0 archive
0.5.0 Oct 8, 2016 Go to the documentation of html_parser 0.5.0 Download html_parser 0.5.0 archive
0.4.0 Oct 2, 2016 Go to the documentation of html_parser 0.4.0 Download html_parser 0.4.0 archive
0.2.0 Oct 1, 2016 Go to the documentation of html_parser 0.2.0 Download html_parser 0.2.0 archive
0.1.1 Oct 1, 2016 Go to the documentation of html_parser 0.1.1 Download html_parser 0.1.1 archive
0.1.0+dev Oct 1, 2016 Go to the documentation of html_parser 0.1.0+dev Download html_parser 0.1.0+dev archive

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
37 / 100
Health:
Code health derived from static analysis. [more]
96 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
46 / 100
Overall score:
Weighted score of the above. [more]
57
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:html_parser/html_parser.dart.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 3 hints.

    Strong-mode analysis of lib/src/visitor.dart failed with the following error:

    line: 75 col: 12
    The expression in an assert must be of type 'bool'.

    Run dartfmt to format lib/src/nodes/attribute_node.dart.

    Similar analysis of the following files failed:

    • lib/src/nodes/element_node.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use html_parser.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
charcode >=1.1.0 <2.0.0 1.1.1
collection ^1.0.0 1.14.9
string_scanner ^1.0.0 1.0.2
Transitive dependencies
path 1.5.1
source_span 1.4.0
Dev dependencies
angular2
benchmark_harness
dart_style
html
test