From bdbc5f632fe153d338a9ec9b6efdbd4cadfaa7d5 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 19 Dec 2017 06:33:44 -0800 Subject: [PATCH 1/3] Split gitHub into gitHubWeb and gitHubFlavored --- README.md | 6 +++++- example/app.dart | 2 +- lib/src/extension_set.dart | 38 +++++++++++++++++++++++++++++++++++++- tool/stats_lib.dart | 2 +- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9970e28e..dcaca0d1 100644 --- a/README.md +++ b/README.md @@ -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()` diff --git a/example/app.dart b/example/app.dart index e0f4c537..9f7c1644 100644 --- a/example/app.dart +++ b/example/app.dart @@ -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() { diff --git a/lib/src/extension_set.dart b/lib/src/extension_set.dart index 863004f9..d18337a3 100644 --- a/lib/src/extension_set.dart +++ b/lib/src/extension_set.dart @@ -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 blockSyntaxes; final List inlineSyntaxes; diff --git a/tool/stats_lib.dart b/tool/stats_lib.dart index 8d06e79a..62bfec2b 100644 --- a/tool/stats_lib.dart +++ b/tool/stats_lib.dart @@ -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.gitHubWeb); final String prefix; final String baseUrl; From 30ade4225857f9a94dba159a4fdfd6c4d9936b30 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Wed, 20 Dec 2017 11:13:34 -0800 Subject: [PATCH 2/3] Duh --- tool/stats_lib.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/stats_lib.dart b/tool/stats_lib.dart index 62bfec2b..15290aa2 100644 --- a/tool/stats_lib.dart +++ b/tool/stats_lib.dart @@ -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.gitHubWeb); + 'gfm', 'https://github.github.com/gfm/', ExtensionSet.gitHubFlavored); final String prefix; final String baseUrl; From 081e0731078ce6c8d26282f5d5348bb9809db9d0 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Wed, 20 Dec 2017 13:29:07 -0800 Subject: [PATCH 3/3] Add to CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34ef832a..1fcb5f88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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