markdown_quill 4.2.0 copy "markdown_quill: ^4.2.0" to clipboard
markdown_quill: ^4.2.0 copied to clipboard

Convert between quill (delta) format and markdown

Markdown Quill #

build workflow codecov pub package

😻 Contributions are always welcomed ❤️ #

Provides converters to convert from markdown to quill (Delta) format and vice versa.

Usage #

Simple #

import 'package:markdown/markdown.dart' as md;
import 'package:markdown_quill/markdown_quill.dart';

// Configure the markdown parser
final mdDocument = md.Document(encodeHtml: false);

final mdToDelta = MarkdownToDelta(markdownDocument: mdDocument);

final deltaToMd = DeltaToMarkdown();

const markdown = '''
# Test
Hello
> Testing

This is an `inline code`

and this is 
``
code block
``
''';

final delta = mdToDelta.convert(markdown);

final markdownAgain = deltaToMd.convert(delta);

Customized #

import 'package:flutter_quill/flutter_quill.dart';
import 'package:markdown/markdown.dart' as md;
import 'package:markdown_quill/markdown_quill.dart';

// Configure the markdown parser
final mdDocument = md.Document(
  encodeHtml: false,
  extensionSet: md.ExtensionSet.gitHubFlavored,

  // you can add custom syntax.
  blockSyntaxes: [const EmbeddableTableSyntax()],
);

final mdToDelta = MarkdownToDelta(
  markdownDocument: mdDocument,

  // you can add custom attributes based on tags
  customElementToBlockAttribute: {
    'h4': (element) => [HeaderAttribute(level: 4)],
  },
  // custom embed
  customElementToEmbeddable: {
    EmbeddableTable.tableType: EmbeddableTable.fromMdSyntax,
  },
);

final deltaToMd = DeltaToMarkdown(
    customEmbedHandlers: {
      EmbeddableTable.tableType: EmbeddableTable.toMdSyntax,
    },
);



const markdown = '''
Hi, this is a test of markdown_quill.

| Syntax      | Description | Test Text     |
| :---        |    :----:   |          ---: |
| Header      | Title       | Here's this   |
| Paragraph   | Text        | And more      |

# H1
ok
# H2
# H3
done
# H4
''';


final delta = mdToDelta.convert(markdown);

final markdownAgain = deltaToMd.convert(delta);

Limitation #

Image #

Currently this convertor doesn't support image alts, only image src will be retained

Block attributes exclusivity #

flutter_quill block attributes have restrictions on how they can be combined.

These block attributes are exclusive and cannot be combined:

  • Header
  • List
  • Code Block
  • Block Quote

if the input markdown is:

> # Foo
> bar
> baz

it will be treated as

> Foo
> bar
> baz

TODO #

  • Improve the output of DeltaToMarkdown
29
likes
130
points
3.84k
downloads

Publisher

unverified uploader

Weekly Downloads

Convert between quill (delta) format and markdown

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

charcode, collection, flutter_quill, markdown

More

Packages that depend on markdown_quill