bbob_dart 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

bbob_dart #

badge

⚡️Blazing fast port of the BBCode parser and transformer bbob in dart.

What's currently ported? #

  • bbob_parser : parses bbcode into a ast.

Usage #

See code in exmaple folder.

What's different from the original bbob? #

bbob_dart is written in dart, which has a sound type system. And with the help of dart, bbob_dart is strongly typed.

I want to render ast into html/markdown... #

You have two ways to render:

  1. Similar to https://github.com/JiLiZART/bbob/blob/master/packages/bbob-html/src/index.js, how bbob renders ast into html.

  2. Similar to https://github.com/dart-lang/markdown/blob/master/lib/src/html_renderer.dart, bbob_dart has implemented an ast which allows you to walk through the tree using visitor pattern.

Office support in bbob_dart for a html renderer might not happen in the near future. Feel free to send a pull request if you have a well-tested implementation.

How fast it is? #

See discussions here. Performance is expected to be on par with original bbob.

Feature requests & bugs

Since this is a port of bbob, feature requests and bug reports should preferably be reported to original bbob repo if it's not directly related to this dart implementation.

0.1.1 #

  • Improve performance so it's on par with original bbob implementation.

  • Some other minor fixes.

0.1.0 #

Initial release.

Synced bbob_parser to https://github.com/JiLiZART/bbob/tree/5291543855a13bd7ddae75189a92e7ace968fca3

example/example.dart

import 'package:bbob_dart/bbob_dart.dart';

main() {
  const validTags = {'url'};

  var ast = parse(
    '''print [b]a[/b] [url=https://github.com]hello world![/url]
  Yes this\'s an exampe''',
    onError: (msg) {
      print(msg);
    },
    openTag: '[',
    closeTag: ']',
    enableEscapeTags: false,
    validTags: validTags,
  );

  /// Parsed ast. Note that `b` is parsed as text because
  /// it's not in [validTags].
  ///
  ///[Text{text: 'print'}, Text{text: ' '}, Text{text: '[b]'}, Text{text: 'a'},
  ///Text{text: '[/b]'}, Text{text: ' '},
  ///Element{tag: 'url', attributes: '{https://github.com: https://github.com}',
  ///children: [Text{text: 'hello'}, Text{text: ' '}, Text{text: 'world!'}]},
  ///Text{text: '
  //'}, Text{text: '  '}, Text{text: 'Yes'}, Text{text: ' '},
  // Text{text: 'this's'}, Text{text: ' '}, Text{text: 'an'}, Text{text: ' '},
  // Text{text: 'exampe'}]

  /// Each [Node] has a [Node.textContent] which can be used to access its
  /// content in raw text format.
  ast.forEach((node) => print(node.textContent));
}

Use this package as a library

1. Depend on it

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


dependencies:
  bbob_dart: ^0.1.1

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:bbob_dart/bbob_dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
39
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Nov 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0-dev.0.5.flutter-a1668566e5 <3.0.0
meta ^1.1.6 1.1.8
Dev dependencies
path ^1.3.1
pedantic ^1.0.0
quiver ^2.0.2
test ^1.0.0