Skip to content

realth000/dart_bbcode_parser

Repository files navigation

dart_bbcode_parser

codecov

BBCode parser written in pure dart with Quill Delta integration support.

This package a dependency of flutter_bbcode_editor, a BBCode editor based on flutter_quill.

Some tags are prepared for the editor but the package can be used standalone without it, even in pure dart environment (without Flutter).

WIP

This package is not ready to publish to pub.dev.

Usage

import 'package:dart_bbcode_parser/src/dart_bbcode_parser.dart';

const code = '[b]bold text[/b]';

// Parse BBCode text to tags, `List<BBCodeTag>` type.
final tags = parseBBCodeTextToTags(code);

// Parsed BoldTag type.
final boldTag = tags[0];
// Parsed TextContent type.
final boldText = boldTag.children[0];

/// Convert BBCode tags to plain text.
final code2 = convertBBCodeToText(tags);

// Or parse BBCode text to Quill Delta.
final delta = parseBBCodeTextToDelta(code);

Features

  • Tags
    • Font size [size=$size]
    • Font color [color=$color]
    • Bold [b]
    • Italic [i]
    • Underline [u]
    • Background color [backcolor=$color]
    • Strikethrough [s]
    • Superscript [sup]
    • Alignment
      • Align left [align=left]
      • Align center [align=center]
      • Align right [align=right]
    • Url [url]
    • Image [img=$width,$height]$image_url[/img]
    • Spoiler [spoiler]
    • Mention user with [@]$user_name[/@]
    • Ordered list [list=1]
    • Bullet list [list]
    • Divider [hr]
    • Code block [code]
    • Quote block [quote]
    • Superscript [sup]
    • Spoiler *
      • Spoiler header [spoiler=$description]
      • Spoiler tail [/spoiler]
    • Free area *
      • Free header [free=$points] or [free]
      • Free tail [/free]
    • Hide area *
      • Hide header [hide=$points] or [hide]
      • Hide tail [/hide]
  • Override tags
  • Custom tags
  • Convert BBCode tags to Quill Delta.
  • Parse text to BBCode tags.
  • Convert BBCode tags back to text.

* Marked tags are extended for flutter_bbcode_editor.

About

BBCode parser written in pure dart with Quill Delta integration support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages