markdownToAnsi function
Converts a markdown string to ANSI-styled terminal text.
This is a convenience function that parses the markdown and renders it using AnsiRenderer.
final styled = markdownToAnsi('''
# Welcome
This is **bold** and *italic*.
- Item 1
- Item 2
''');
print(styled);
Implementation
String markdownToAnsi(String markdown, {AnsiRendererOptions? options}) {
final document = Document(extensionSet: ExtensionSet.gitHubFlavored);
final nodes = document.parse(markdown);
return AnsiRenderer(options: options).render(nodes);
}