Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## 1.1.0

* 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.

## 1.0.0

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ parameter. Right now there are two extension sets:
* `new InlineHtmlSyntax()`
* `const FencedCodeBlockSyntax()`

* `ExtensionSet.gitHub` includes five extensions:
* `ExtensionSet.gitHubWeb` includes five extensions:

* `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()`
* `const TableSyntax()`

Expand Down
2 changes: 1 addition & 1 deletion example/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ md.ExtensionSet extensionSet;
final extensionSets = {
'basic-radio': md.ExtensionSet.none,
'commonmark-radio': md.ExtensionSet.commonMark,
'gfm-radio': md.ExtensionSet.gitHub,
'gfm-radio': md.ExtensionSet.gitHubWeb,
};

void main() {
Expand Down
38 changes: 37 additions & 1 deletion lib/src/extension_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,51 @@ import 'inline_parser.dart';
/// For example, the [gitHub] set of syntax extensions allows users to output
/// HTML from their Markdown in a similar fashion to GitHub's parsing.
class ExtensionSet {
/// The [none] extension set renders Markdown similar to [Markdown.pl].
///
/// However, this set does not render _exactly_ the same as Markdown.pl;
/// rather it is more-or-less the CommonMark standard of Markdown, without
/// fenced code blocks, or inline HTML.
///
/// [Markdown.pl]: http://daringfireball.net/projects/markdown/syntax
static final ExtensionSet none = new ExtensionSet([], []);

/// The [commonMark] extension set is close to compliance with [CommonMark].
///
/// [CommonMark]: http://commonmark.org/
static final ExtensionSet commonMark = new ExtensionSet(
[const FencedCodeBlockSyntax()], [new InlineHtmlSyntax()]);

static final ExtensionSet gitHub = new ExtensionSet(
/// The [gitHubWeb] extension set renders Markdown similarly to GitHub.
///
/// This is different from the [gitHubFlavored] extension set in that GitHub
/// actually renders HTML different from straight [GitHub flavored Markdown].
///
/// (The only difference currently is that [gitHubWeb] renders headers with
/// linkable IDs.)
///
/// [GitHub flavored Markdown]: https://github.github.com/gfm/
static final ExtensionSet gitHubWeb = new ExtensionSet([
const FencedCodeBlockSyntax(),
const HeaderWithIdSyntax(),
const SetextHeaderWithIdSyntax(),
const TableSyntax()
], [
new InlineHtmlSyntax()
]);

/// The [gitHubFlavored] extension set is close to compliance with the [GitHub
/// flavored Markdown spec].
///
/// [GitHub flavored Markdown]: https://github.github.com/gfm/
static final ExtensionSet gitHubFlavored = new ExtensionSet(
[const FencedCodeBlockSyntax(), const TableSyntax()],
[new InlineHtmlSyntax()]);

/// The deprecated name for the [gitHubFlavored] extension set.
@deprecated
static final ExtensionSet gitHub = gitHubFlavored;

final List<BlockSyntax> blockSyntaxes;
final List<InlineSyntax> inlineSyntaxes;

Expand Down
2 changes: 1 addition & 1 deletion tool/stats_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Config {
static final Config commonMarkConfig =
new Config._('common_mark', 'http://spec.commonmark.org/0.28/', null);
static final Config gfmConfig = new Config._(
'gfm', 'https://github.github.com/gfm/', ExtensionSet.gitHub);
'gfm', 'https://github.github.com/gfm/', ExtensionSet.gitHubFlavored);

final String prefix;
final String baseUrl;
Expand Down