markdownToDiv function

HTMLDivElement markdownToDiv(
  1. String markdown, {
  2. bool normalize = true,
  3. Iterable<BlockSyntax>? blockSyntaxes,
  4. Iterable<InlineSyntax>? inlineSyntaxes,
  5. ExtensionSet? extensionSet,
  6. Resolver? linkResolver,
  7. Resolver? imageLinkResolver,
  8. bool inlineOnly = false,
})

Converts a markdown document into a HTML in a div node.

Links are extended to accept attributes:

  [Go to Google](https://www.google.cn/){:target="_blank"}

markdown The markdown document. normalize If true normalizes indent.

Implementation

HTMLDivElement markdownToDiv(
  String markdown, {
  bool normalize = true,
  Iterable<mk.BlockSyntax>? blockSyntaxes,
  Iterable<mk.InlineSyntax>? inlineSyntaxes,
  mk.ExtensionSet? extensionSet,
  mk.Resolver? linkResolver,
  mk.Resolver? imageLinkResolver,
  bool inlineOnly = false,
}) {
  if (markdown.isEmpty) return createDivInline();
  var html = markdownToHtml(
    markdown,
    normalize: normalize,
    blockSyntaxes: blockSyntaxes,
    inlineSyntaxes: inlineSyntaxes,
    extensionSet: extensionSet,
    linkResolver: linkResolver,
    imageLinkResolver: imageLinkResolver,
    inlineOnly: inlineOnly,
  );
  return createDivInline(html: html);
}