flutter-quill
flutter-quill copied to clipboard
Converting Markdown to Quill document (Delta) format
Is there an existing issue for this?
- [X] I have searched the existing issues
The question
I am trying to convert basic MarkDown to a formatted Quill document, but the approach that I believe is right only parses the in-line markdown (like bold and italics) and not markdown like headers and block markdown like an ordered list. What am I doing wrong?
Code snippet:
final markdownDocument = md.Document(inlineSyntaxes: [ // not sure I need to specify these, but I did
md.EmphasisSyntax.asterisk(),
md.EmphasisSyntax.underscore()
], blockSyntaxes: const [ // similarly, not sure I need to specify these as they are pretty standard
md.HeaderSyntax(),
md.UnorderedListSyntax(),
md.OrderedListSyntax()
]);
final quillDocDelta =
MarkdownToDelta(markdownDocument: markdownDocument)
.convert(markDownString); // markDownString is a typical markdown formatted document
result = jsonEncode(quillDocDelta.toJson());
The result can be used to create a Quill document, but as described above, only some of the formatting makes it into the document.
Almost convert package like Html to Quill, Md to Quill are not good, so I have 2 options for u.
- U using Quill format for storage (not need convert) (best solution)
- Or, You write a new convert function, which will take about 8-12 hours of u (not good, you need very effort and you can mistakes in some cases)
Thanks @hoangsang17th . It looks like your question is answered.