strip_markdown 1.1.0 copy "strip_markdown: ^1.1.0" to clipboard
strip_markdown: ^1.1.0 copied to clipboard

A Dart package that removes Markdown formatting from text, converting it to plain text. Port of the popular Node.js remove-markdown package. Supports headers, emphasis, links, images, code blocks, lis [...]

example/example.dart

// ignore_for_file: avoid_print

import 'package:strip_markdown/strip_markdown.dart';

void main() {
  // Basic markdown removal
  const String markdown = '''
# Heading
This is **bold** and *italic* text with a [link](https://example.com).

## Another heading
- List item 1
- List item 2

> This is a blockquote

`inline code` and ```code block```

![Image alt text](image.png)
''';

  final String plainText = removeMd(markdown);
  print('Original markdown:');
  print(markdown);
  print('\nStripped text:');
  print(plainText);

  // Using options
  const String markdownWithOptions = '- **Important** item\n- Another item';

  // Keep list leaders but replace with custom character
  final String withCustomList = removeMd(
    markdownWithOptions,
    const RemoveMarkdownOptions(listUnicodeChar: '•'),
  );
  print('\nWith custom list character:');
  print(withCustomList);

  // Remove list leaders completely
  final String withoutLists = removeMd(
    markdownWithOptions,
    const RemoveMarkdownOptions(),
  );
  print('\nWithout list leaders:');
  print(withoutLists);

  // Keep image alt text
  const String imageMarkdown = 'Check out this ![cool image](photo.jpg)!';
  final String withAltText = removeMd(
    imageMarkdown,
    const RemoveMarkdownOptions(),
  );
  print('\nWith image alt text:');
  print(withAltText);
}
2
likes
140
points
448
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart package that removes Markdown formatting from text, converting it to plain text. Port of the popular Node.js remove-markdown package. Supports headers, emphasis, links, images, code blocks, lists, blockquotes, and more.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on strip_markdown