markdownToHtml function
String
markdownToHtml(
- String markdown, {
- Iterable<
BlockSyntax> blockSyntaxes = const [], - Iterable<
InlineSyntax> inlineSyntaxes = const [], - ExtensionSet? extensionSet,
- Resolver? linkResolver,
- Resolver? imageLinkResolver,
- bool inlineOnly = false,
- bool checkable = false,
- bool emptyListDisabled = false,
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 checkable = false,
bool emptyListDisabled = false,
}) {
var document = Document(
blockSyntaxes: blockSyntaxes,
inlineSyntaxes: inlineSyntaxes,
extensionSet: extensionSet,
linkResolver: linkResolver,
imageLinkResolver: imageLinkResolver,
checkable: checkable,
emptyListDisabled: emptyListDisabled,
);
if (inlineOnly) return renderToHtml(document.parseInline(markdown));
// Replace windows line endings with unix line endings, and split.
var lines = markdown.replaceAll('\r\n', '\n').split('\n');
return renderToHtml(document.parseLines(lines)) + '\n';
}