commit | 1fa91ef59b3a5182e4f3b849c43b0f9a5d2a7b73 | [log] [tgz] |
---|---|---|
author | Sam Rawlins <sam.rawlins@gmail.com> | Fri Aug 05 20:52:53 2016 |
committer | GitHub <noreply@github.com> | Fri Aug 05 20:52:53 2016 |
tree | aa1e803beafb6ff80d77cf8c67cd7e492ee6614d | |
parent | e245a21a91748253150166fb32ddd9596afa99c2 [diff] | |
parent | 5b399619fd0640d4406d1694c3063fe7db2d928d [diff] |
Merge pull request #117 from dart-lang/more_details Be more clear in stats about a successful test
A portable Markdown library written in Dart. It can parse Markdown into HTML on both the client and server.
import 'package:markdown/markdown.dart'; void main() { print(markdownToHtml('Hello *Markdown*')); //=> <p>Hello <em>Markdown</em></p> }
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
).For example:
import 'package:markdown/markdown.dart'; void main() { print(markdownToHtml('Hello <span class="green">Markdown</span>', inlineSyntaxes: [new InlineHtmlSyntax()])); //=> <p>Hello <span class="green">Markdown</span></p> }
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()
You can create and use your own syntaxes.
import 'package:markdown/markdown.dart'; void main() { var syntaxes = [new TextSyntax('nyan', sub: '~=[,,_,,]:3')]; print(markdownToHtml('nyan', inlineSyntaxes: syntaxes)); //=> <p>~=[,,_,,]:3</p> }
This package contains a number of files in the tool
directory for tracking compliance with CommonMark.
dart tool/common_mark_stats.dart --update-files
to update the per-test results tool/common_mark_stats.json
and the test summary tool/common_mark_stats.txt
.Check out the CommonMark source. Make sure you checkout a major release.
Dump the test output overwriting the existing tests file.
/path/to/common_mark_dir> python3 test/spec_tests.py --dump-tests \ > /path/to/markdown.dart/tool/common_mark_tests.json
Update the stats files as described above. Note any changes in the results.
Update any references to the existing spec by search for http://spec.commonmark.org/0.26
in the repository. (Including this one.) Verify the updated links are still valid.
Commit changes, including a corresponding note in CHANGELOG.md
.