markdownToHtml function
String
markdownToHtml(
- String markdown, {
- Iterable<
BlockSyntax> blockSyntaxes = const [], - Iterable<
InlineSyntax> inlineSyntaxes = const [], - ExtensionSet? extensionSet,
- Resolver? linkResolver,
- Resolver? imageLinkResolver,
- bool inlineOnly = false,
- bool encodeHtml = true,
- bool enableTagfilter = false,
- bool withDefaultBlockSyntaxes = true,
- bool withDefaultInlineSyntaxes = true,
Converts the given string of Markdown to HTML.
Implementation
String markdownToHtml(
String markdown, {
Iterable<BlockSyntax> blockSyntaxes = const [],
Iterable<InlineSyntax> inlineSyntaxes = const [],
ExtensionSet? extensionSet,
Resolver? linkResolver,
Resolver? imageLinkResolver,
bool inlineOnly = false,
bool encodeHtml = true,
bool enableTagfilter = false,
bool withDefaultBlockSyntaxes = true,
bool withDefaultInlineSyntaxes = true,
}) {
final document = Document(
blockSyntaxes: blockSyntaxes,
inlineSyntaxes: inlineSyntaxes,
extensionSet: extensionSet,
linkResolver: linkResolver,
imageLinkResolver: imageLinkResolver,
encodeHtml: encodeHtml,
withDefaultBlockSyntaxes: withDefaultBlockSyntaxes,
withDefaultInlineSyntaxes: withDefaultInlineSyntaxes,
);
if (inlineOnly) return renderToHtml(document.parseInline(markdown));
final nodes = document.parse(markdown);
return '${renderToHtml(nodes, enableTagfilter: enableTagfilter)}\n';
}