flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

Converting Markdown to Quill document (Delta) format

Open 781flyingdutchman opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

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.

781flyingdutchman avatar May 08 '24 03:05 781flyingdutchman

Almost convert package like Html to Quill, Md to Quill are not good, so I have 2 options for u.

  1. U using Quill format for storage (not need convert) (best solution)
  2. 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)

hoangsang17th avatar May 13 '24 10:05 hoangsang17th

Thanks @hoangsang17th . It looks like your question is answered.

singerdmx avatar Jun 15 '24 17:06 singerdmx