Skip to content

Commit

Permalink
Standardize CommonMark spec links to https and v0.30 (#553)
Browse files Browse the repository at this point in the history
* Standardize CommonMark links to https and v0.30

* Run formatter
  • Loading branch information
parlough committed Aug 26, 2023
1 parent faabb1a commit 56e75df
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 7.1.2-wip

* Update all CommonMark specification links to 0.30.

## 7.1.1

* Fix delimiter row matching pattern for tables.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ compliance with [CommonMark].

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
`https://spec.commonmark.org/0.28` in the repository. (Including this one.)
`https://spec.commonmark.org/0.30/` in the repository. (Including this one.)
Verify the updated links are still valid.
5. Commit changes, including a corresponding note in `CHANGELOG.md`.

Expand Down
3 changes: 2 additions & 1 deletion lib/src/block_syntaxes/fenced_code_block_syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import 'block_syntax.dart';

/// Parses preformatted code blocks between two ~~~ or ``` sequences.
///
/// See the CommonMark spec: https://spec.commonmark.org/0.29/#fenced-code-blocks
/// See the CommonMark spec:
/// https://spec.commonmark.org/0.30/#fenced-code-blocks
class FencedCodeBlockSyntax extends BlockSyntax {
@override
RegExp get pattern => codeFencePattern;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/block_syntaxes/list_syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ abstract class ListSyntax extends BlockSyntax {
@override
bool canEndBlock(BlockParser parser) {
// An empty list cannot interrupt a paragraph. See
// https://spec.commonmark.org/0.29/#example-255.
// https://spec.commonmark.org/0.30/#example-285.
// Ideally, [BlockSyntax.canEndBlock] should be changed to be a method
// which accepts a [BlockParser], but this would be a breaking change,
// so we're going with this temporarily.
final match = pattern.firstMatch(parser.current.content)!;

// Allow only lists starting with 1 to interrupt paragraphs, if it is an
// ordered list. See https://spec.commonmark.org/0.30/#example-304.
// But there shuold be an exception for nested ordered lists, for example:
// But there should be an exception for nested ordered lists, for example:
// ```
// 1. one
// 2. two
Expand Down Expand Up @@ -276,7 +276,7 @@ abstract class ListSyntax extends BlockSyntax {
}

// Must strip paragraph tags if the list is "tight".
// http://spec.commonmark.org/0.28/#lists
// https://spec.commonmark.org/0.30/#lists
final listIsTight = !anyEmptyLines && !anyEmptyLinesBetweenBlocks;

if (listIsTight) {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,19 @@ extension _ElementExt on Element {
}

/// A [link reference
/// definition](http://spec.commonmark.org/0.28/#link-reference-definitions).
/// definition](https://spec.commonmark.org/0.30/#link-reference-definitions).
class LinkReference {
/// The [link label](http://spec.commonmark.org/0.28/#link-label).
/// The [link label](https://spec.commonmark.org/0.30/#link-label).
///
/// Temporarily, this class is also being used to represent the link data for
/// an inline link (the destination and title), but this should change before
/// the package is released.
final String label;

/// The [link destination](http://spec.commonmark.org/0.28/#link-destination).
/// The [link destination](https://spec.commonmark.org/0.30/#link-destination).
final String destination;

/// The [link title](http://spec.commonmark.org/0.28/#link-title).
/// The [link title](https://spec.commonmark.org/0.30/#link-title).
final String? title;

/// Construct a new [LinkReference], with all necessary fields.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/inline_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class InlineParser {
while (!isDone) {
// A right bracket (']') is special. Hitting this character triggers the
// "look for link or image" procedure.
// See https://spec.commonmark.org/0.29/#an-algorithm-for-parsing-nested-emphasis-and-links.
// See https://spec.commonmark.org/0.30/#an-algorithm-for-parsing-nested-emphasis-and-links.
if (charAt(pos) == $rbracket) {
writeText();
_linkOrImage();
Expand All @@ -125,7 +125,7 @@ class InlineParser {
/// image.
///
/// This is the "look for link or image" routine from the CommonMark spec:
/// https://spec.commonmark.org/0.29/#-look-for-link-or-image-.
/// https://spec.commonmark.org/0.30/#look-for-link-or-image.
void _linkOrImage() {
final index = _delimiterStack
.lastIndexWhere((d) => d.char == $lbracket || d.char == $exclamation);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/inline_syntaxes/delimiter_syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DelimiterSyntax extends InlineSyntax {
/// Whether this is parsed according to the same nesting rules as [emphasis
/// delimiters][].
///
/// [emphasis delimiters]: http://spec.commonmark.org/0.28/#can-open-emphasis
/// [emphasis delimiters]: https://spec.commonmark.org/0.30/#can-open-emphasis
final bool requiresDelimiterRun;

/// Whether to allow intra-word delimiter runs. CommonMark emphasis and
Expand Down Expand Up @@ -302,14 +302,14 @@ class DelimiterRun implements Delimiter {
}

// If it is a left-flanking delimiter run, see
// http://spec.commonmark.org/0.30/#left-flanking-delimiter-run.
// https://spec.commonmark.org/0.30/#left-flanking-delimiter-run.
final isLeftFlanking = !followedByWhitespace &&
(!followedByPunctuation ||
precededByWhitespace ||
precededByPunctuation);

// If it is a right-flanking delimiter run, see
// http://spec.commonmark.org/0.30/#right-flanking-delimiter-run.
// https://spec.commonmark.org/0.30/#right-flanking-delimiter-run.
final isRightFlanking = !precededByWhitespace &&
(!precededByPunctuation ||
followedByWhitespace ||
Expand Down
2 changes: 1 addition & 1 deletion lib/src/inline_syntaxes/email_autolink_syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'inline_syntax.dart';

/// Matches autolinks like `<foo@bar.example.com>`.
///
/// See <http://spec.commonmark.org/0.28/#email-address>.
/// See <https://spec.commonmark.org/0.30/#email-address>.
class EmailAutolinkSyntax extends InlineSyntax {
static const _email =
r'''[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}'''
Expand Down
2 changes: 1 addition & 1 deletion lib/src/inline_syntaxes/inline_html_syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '../charcode.dart';
import '../patterns.dart';

/// Leave inline HTML tags alone, from
/// [CommonMark 0.30](http://spec.commonmark.org/0.30/#raw-html).
/// [CommonMark 0.30](https://spec.commonmark.org/0.30/#raw-html).
///
/// This is not actually a good definition (nor CommonMark's) of an HTML tag,
/// but it is fast. It will leave text like `<a href='hi">` alone, which is
Expand Down
6 changes: 3 additions & 3 deletions lib/src/inline_syntaxes/link_syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class LinkSyntax extends DelimiterSyntax {
parser.advanceBy(1);
final next = parser.charAt(parser.pos);
// TODO: Follow the backslash spec better here.
// http://spec.commonmark.org/0.29/#backslash-escapes
// https://spec.commonmark.org/0.30/#backslash-escapes
if (next != $backslash && next != $gt) {
buffer.writeCharCode(char);
}
Expand Down Expand Up @@ -327,7 +327,7 @@ class LinkSyntax extends DelimiterSyntax {
/// Returns the link if it was successfully created, `null` otherwise.
InlineLink? _parseInlineBareDestinationLink(InlineParser parser) {
// According to
// [CommonMark](http://spec.commonmark.org/0.28/#link-destination):
// [CommonMark](https://spec.commonmark.org/0.30/#link-destination):
//
// > A link destination consists of [...] a nonempty sequence of
// > characters [...], and includes parentheses only if (a) they are
Expand All @@ -348,7 +348,7 @@ class LinkSyntax extends DelimiterSyntax {
final next = parser.charAt(parser.pos);
// Parentheses may be escaped.
//
// http://spec.commonmark.org/0.28/#example-467
// https://spec.commonmark.org/0.30/#example-494
if (next != $backslash && next != $lparen && next != $rparen) {
buffer.writeCharCode(char);
}
Expand Down
2 changes: 1 addition & 1 deletion tool/stats_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Map<String, List<CommonMarkTestCase>> loadCommonMarkSections(
class Config {
static final Config commonMarkConfig = Config._(
'common_mark',
'http://spec.commonmark.org/0.28/',
'https://spec.commonmark.org/0.30/',
);
static final Config gfmConfig = Config._(
'gfm',
Expand Down

0 comments on commit 56e75df

Please sign in to comment.