markd 1.1.1+2

  • Installing
  • Versions
  • 89

A fork of dart-markdown for easy customization of Markdown syntaxes.


  • LinkMapper introduced to simplify the customization of LinkSyntax.
  • and introduced for using fully customized line syntaxes. They are used in pair if all parsing shares the same set of syntaxes.
  • BlockParser.safeBlockParsers introduced for not parsing HTML tags at all.
  • Document's constructor introduced additional arguments, options, blockParserBuilder and inlineParserBuilder for easy customization.
  • Attribute's names are not sorted
  • InlineSyntax.match introduced for easy overriding.
  • InlineSyntax's constructor introduces the caseSensitive argument
  • FencedCodeBlockSyntax.getLanguageClass introduced for generating custom CSS class
  • TableSyntax.processCellContent introduced for pre-processing cell's content
  • Allow a link containing parenthesis and quotes, e.g. [foo](link(1).jpg)
  • TagSyntax.endMatch() introduced to encapsulate TagSyntax.endPattern



Who Uses

  • Quire - a simple, collaborative, multi-level task management tool.


A portable Markdown library written in Dart. It can parse Markdown into HTML on both the client and server.

Play with it at


import 'package:markd/markdown.dart';

void main() {
  print(markdownToHtml('Hello *Markdown*'));
  //=> <p>Hello <em>Markdown</em></p>

Syntax extensions

A few Markdown extensions, beyond what was specified in the original Perl Markdown implementation, are supported. By default, the ones supported in CommonMark are enabled. Any individual extension can be enabled by specifying an Array of extension syntaxes in the blockSyntaxes or inlineSyntaxes argument of markdownToHtml.

The currently supported inline extension syntaxes are:

  • new InlineHtmlSyntax() - approximately CommonMark's definition of "Raw HTML".

The currently supported block extension syntaxes are:

  • const FencedCodeBlockSyntax() - Code blocks familiar to Pandoc and PHP Markdown Extra users.
  • const HeaderWithIdSyntax() - ATX-style headers have generated IDs, for link anchors (akin to Pandoc's auto_identifiers).
  • const SetextHeaderWithIdSyntax() - Setext-style headers have generated IDs for link anchors (akin to Pandoc's auto_identifiers).
  • const TableSyntax() - Table syntax familiar to GitHub, PHP Markdown Extra, and Pandoc users.

For example:

import 'package:markd/markdown.dart';

void main() {
  print(markdownToHtml('Hello <span class="green">Markdown</span>',
      inlineSyntaxes: [new InlineHtmlSyntax()]));
  //=> <p>Hello <span class="green">Markdown</span></p>

Extension sets

To make extension management easy, you can also just specify an extension set. Both markdownToHtml() and new Document() accept an extensionSet named parameter. Right now there are two extension sets:

  • ExtensionSet.none includes no extensions. With no extensions, Markdown documents will be parsed closely to how they might be parsed by the original Perl Markdown implementation.

  • ExtensionSet.commonMark includes two extensions so far, which bring this package's Markdown parsing closer to what is found in the CommonMark spec:

    • new InlineHtmlSyntax()
    • const FencedCodeBlockSyntax()
  • ExtensionSet.gitHubWeb includes seven extensions:

    • new EmojiSyntax()
    • new InlineHtmlSyntax()
    • const HeaderWithIdSyntax(), which adds id attributes to ATX-style headers, for easy intra-document linking.
    • const SetextHeaderWithIdSyntax(), which adds id attributes to Setext-style headers, for easy intra-document linking.
    • const FencedCodeBlockSyntax()
    • new StrikethroughSyntax()
    • const TableSyntax()

Custom syntax extensions

You can create and use your own syntaxes.

import 'package:markd/markdown.dart';

void main() {
  var syntaxes = [new TextSyntax('nyan', sub: '~=[,,_,,]:3')];
  print(markdownToHtml('nyan', inlineSyntaxes: syntaxes));
  //=> <p>~=[,,_,,]:3</p>

HTML sanitization

This package offers no features in the way of HTML sanitization. Read Estevão Soares dos Santos's great article, ["Markdown's XSS Vulnerability (and how to mitigate it)"], to learn more.

The authors recommend that you perform any necessary sanitization on the resulting HTML, for example via dart:html's NodeValidator.

CommonMark compliance

This package contains a number of files in the tool directory for tracking compliance with CommonMark.

Updating CommonMark stats when changing the implementation

  1. Update the library and test code, making sure that tests still pass.
  2. Run dart tool/stats.dart --update-files to update the per-test results tool/common_mark_stats.json and the test summary tool/common_mark_stats.txt.
  3. Verify that more tests now pass – or at least, no more tests fail.
  4. Make sure you include the updated stats files in your commit.

Updating the CommonMark test file for a spec update

  1. Check out the CommonMark source. Make sure you checkout a major release.

  2. Dump the test output overwriting the existing tests file.

    > cd /path/to/common_mark_dir
    > python3 test/ --dump-tests \
  3. Update the stats files as described above. Note any changes in the results.

  4. Update any references to the existing spec by search for in the repository. (Including this one.) Verify the updated links are still valid.

  5. Commit changes, including a corresponding note in


  • Overhaul support for emphasis (*foo* and _foo_) and strong emphasis (**foo** and __foo__), dramatically improving CommonMark compliance.

  • Improve support for tab characters, and horizontal rules.

  • Add support for GitHub Flavored Markdown's Strikethrough extension. See the GFM spec.

  • The above fixes raise compliance with the CommonMark specs to 90%, and compliance with the GFM specs to 87%.

  • Allow the binary script to take a --extension-set option.

    A reminder: You can run bin/markdown.dart from anywhere via:

    $ pub global activate markdown
    $ markdown


  • Add support for GitHub's colon-based Emoji syntax. 🎉! This is available in the gitHubWeb extension set.


  • Make the constructor for ExtensionSet public, for tools like dartdoc.
  • Split the gitHub ExtensionSet into two sets: gitHubFlavored, which represents the GitHub Flavored Markdown spec, and gitHubWeb, which represents what GitHub actually renders Markdown.


  • Fix issue where accept could cause an exception.
  • Remove deprecated escapeHtml function.
  • Fix compliance with auto-links, including support for email addresses.
  • Updated ExtensionSet.gitHub to more closely align with GitHub markdown.


  • CondensedHtmlRenderer is aded for generating HTML without extra linefeeds.
  • The Options class is removed. It always generates \n for line breaks.
  • InlineParser.simpleSyntaxes is introduced


  • Fix bug with lazy blockquote continuations (#162)
  • Fix bug with list item continuations (#156)


  • Deprecate escapeHtml. This code exists in dart:convert.


  • Fix reference code links inside blockquotes.
  • Add src/util.dart to exports.


  • Add version information:
    • dart bin/markdown.dart --version now shows the package version number.
    • The playground app now shows the version number.
  • Improve autolink parsing.
  • Add new table syntax: TableSyntax.
  • Add new ExtensionSet that includes the table syntax: ExtensionSet.gitHub.
  • For development: added tool/
  • Support multiline Setext headers.
  • Handle loose-vs-strict list items better.
  • Support ordered lists that start with a number other than 1.


  • Add playground app at


  • Parse HTML blocks more accurately, according to CommonMark.
  • Support shortcut reference links.
  • Don't allow an indented code block to interrupt a paragraph.
  • Change definition of "loose" and "strict" lists (items wrapped in paragraph tags vs not) to CommonMark's. The primary difference is that any single list item can trigger the entire list to be marked as "loose", rather than defining "looseness" on each specific item.
  • Fix paragraph continuations in blockquotes and list items.
  • Fix silly typing bug with tool/common_mark_stats.dart, which resulted in a dramatic overestimate of our CommonMark compliance.
  • There are now 427/613 (69%) passing CommonMark v0.25 specs.


  • Parse hard line breaks properly (#86). Thanks @mehaase!
  • Fix processing of [ ... ] syntax when no resolver is specified (#92).
  • There are now 401/613 (65%) passing CommonMark v0.24 specs. (Actually: after 0f64c8f the actual number of passing tests was 352/613 (57%).)


  • BREAKING: Now following the CommonMark spec for fenced code blocks. If a language (info string) is provided, it is added as a class to the code element with a language- prefix.
  • BREAKING: Now following the CommonMark spec for images. Previously, ![text](img.png) would compile too <a href="img.prg"><img src="img.prg" alt="text"></img></a>. That same code will now compile to <img src="img.png" alt="text" />.
  • Fix all strong mode errors.


  • BREAKING: The text [foo] (bar) no longer renders as an inline link (#53).
  • BREAKING: Change list parsing to allow lists to begin immediately after a preceding block element, without a blank line in between.
  • Formalize an API for Markdown extensions (#43).
  • Introduce ExtensionSets. FencedCodeBlock is considered an extension, but existing usage of markdownToHtml() and new Document() will use the default extension set, which is ExtensionSet.commonMark, which includes FencedCodeBlock.
  • Inline HTML syntax support; This is also considered an extension (#18).
  • The text [foo]() now renders as an inline link.
  • Whitespace now allowed between a link's destination and title (#65).
  • Header identifier support in the HeaderWithIdSyntax and SetextHeaderWithIdSyntax extensions.
  • Implement backslash-escaping so that Markdown syntax can be escaped, such as [foo]\(bar) ==> <p>[foo](bar)</p>.
  • Support for hard line breaks with either \\\n or <code> \n</code> (#30, #60).
  • New public method for BlockParser: peek(int linesAhead), meant for use in subclasses.
  • New public members for ListSyntax: blocksInList and determineBlockItems(), meant for use in subclasses.
  • Improve public docs (better, and more of them).


  • Breaking: Remove (probably unused) fields: LinkSyntax.resolved, InlineParser.currentSource.
  • Switch tests to use test instead of unittest.
  • Fix a few bugs in inline code syntax.
  • Ignore underscores inside words (#41).


  • Allow resolving links that contain inline syntax (#42).


  • Updated homepage.


  • Formatted code.

  • Updated readme.

1. Depend on it

Add this to your package's pubspec.yaml file:

  markd: "^1.1.1+2"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:markd/markdown.dart';
Version Uploaded Documentation Archive
1.1.1+2 Jan 15, 2018 Go to the documentation of markd 1.1.1+2 Download markd 1.1.1+2 archive
1.1.1+1 Jan 12, 2018 Go to the documentation of markd 1.1.1+1 Download markd 1.1.1+1 archive
1.1.1 Jan 12, 2018 Go to the documentation of markd 1.1.1 Download markd 1.1.1 archive
0.11.5+6 Dec 17, 2017 Go to the documentation of markd 0.11.5+6 Download markd 0.11.5+6 archive
0.11.5+5 Dec 13, 2017 Go to the documentation of markd 0.11.5+5 Download markd 0.11.5+5 archive
0.11.5+4 Dec 8, 2017 Go to the documentation of markd 0.11.5+4 Download markd 0.11.5+4 archive
0.11.5+3 Dec 7, 2017 Go to the documentation of markd 0.11.5+3 Download markd 0.11.5+3 archive
0.11.5+2 Dec 5, 2017 Go to the documentation of markd 0.11.5+2 Download markd 0.11.5+2 archive
0.11.5+1 Nov 2, 2017 Go to the documentation of markd 0.11.5+1 Download markd 0.11.5+1 archive
0.11.5 Oct 31, 2017 Go to the documentation of markd 0.11.5 Download markd 0.11.5 archive

All 37 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
80 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
95 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, web, other

No platform restriction found in libraries.


  • Use constrained dependencies.

    The pubspec.yaml contains 2 dependencies without version constraints. Specify version ranges for the following dependencies: args, rikulo_commons.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use markd.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.12.0 <2.0.0
args any 1.3.0
rikulo_commons any 2.3.6
Transitive dependencies
logging 0.11.3+1
mime 0.9.6
Dev dependencies
browser any
collection ^1.2.0
expected_output ^1.1.0
html >=0.12.2 <0.14.0
js ^0.6.1
path ^1.3.1
test ^0.12.4+1
yaml ^2.1.8