marked 0.2.3 marked: ^0.2.3 copied to clipboard
A simple Markdown parser for Dart. Create your own custom Markdown syntax.
import 'package:marked/marked.dart';
final markdown = Markdown.map({
'**': (text, match) => '<b>$text</b>',
'*': (text, match) => '<i>$text</i>',
'***': (text, match) => '<i>$text</i>',
'__': (text, match) => '<u>$text</u>',
'<custom>': (text, match) => '<tag>$text</tag>',
}, placeholders: {
MarkdownPlaceholder.enclosed(
'from here', end: 'to here', (text, match) => '[$text]'),
});
void main() {
print(markdown.apply('''
Hello **World**!
__Looks *pretty* easy__
<custom>Custom tags</custom>
from here ... do anything ... to here
'''));
// Output:
// Hello <b>World</b>!
// <u>Looks <i>pretty</i> easy</u>
// <tag>Custom tags</tag>
// [ ... do anything ... ]
}