tagser 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 48

Overview #

A library for Dart developers.

Simple tag-based document parser. It is not about HTML parsing. You can use whatever tags you want.

Available types of tags:

  • Self closing tags:
  • Block tags:

Attributes types:

  • bool:
  • with value:

Methods #

parse(String source) - parsing source string of tags into a list of Tag objects. html(List<Tag> tags) - converting a list of Tag objects into a correct HTML body.

Usage #

A simple usage example:

import 'package:tagser/tagser.dart';

main() {
  var tagser = new Tagser();
  var source = '<line show/><hello> Hello bro </hello><br />';
  var tags =  tagser.parse(source);
  var html = tagser.html(tags);
  print(html); //prints: <line show="true"></line><hello> Hello bro </hello><br></br>

Notes #

  • Tag names are case sensitive. Open and close tags in block tag declaration should have the same spelling. It can be changed by passing "ignoreCase": true as option to Tagser
  • Attribute names are case sensitive: attribute A and attribute a are not the same

Restrictions #

  • All self closing tags should have slash before closing bracket. Using <br> tag without slash will cause an error.
  • No spaces allowed between open bracket and tag name: < tag /> - will cause an error
  • No spaces allowed between slash and close bracket : <tag / > - will cause an error
  • No spaces allowed in attribute declaration:
  • <tag A = 'value' /> - error
  • <tag A= 'value' /> - error
  • <tag A ='value' /> - error

Options #

You can pass options to the Tagser constructor or set them with setOption() method.

Available options:

  • ignoreCase - enables or disables case ignoring of opening and closing tag; false by default

1.0.1 #

  • "End of source" error type handling added
  • Options now can be passed to a Tagser constructor.
  • ignoreCase option available now. If true tag name spelling will be ignored.

1.0.2 #

  • Empty valued attributes now available. Example: attr=""
  • new Tagser method - .html(tags) - where tags is a list of tags from .parse() method. This method returns correct displayable HTML for any tags;


import 'package:tagser/tagser.dart';

void main() {
  final t = Tagser();

  final source = '''

  final tags = t.parse(source);


Use this package as a library

1. Depend on it

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

  tagser: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:tagser/tagser.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health suggestions

Format lib/src/attribute.dart.

Run dartfmt to format lib/src/attribute.dart.

Format lib/src/const.dart.

Run dartfmt to format lib/src/const.dart.

Format lib/src/context.dart.

Run dartfmt to format lib/src/context.dart.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/error.dart (Run dartfmt to format lib/src/error.dart.)
  • lib/src/result.dart (Run dartfmt to format lib/src/result.dart.)
  • lib/src/tag.dart (Run dartfmt to format lib/src/tag.dart.)
  • lib/src/test.dart (Run dartfmt to format lib/src/test.dart.)
  • lib/src/utils.dart (Run dartfmt to format lib/src/utils.dart.)

Maintenance suggestions

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0
test_coverage ^0.3.0