diff --git a/CHANGELOG.md b/CHANGELOG.md index ee08de91..42073b7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.2.1 + +* Address a termination issue with GitHub alert syntax parsing. + ## 7.2.0 * Require Dart `^3.1.0`. diff --git a/lib/src/block_syntaxes/alert_block_syntax.dart b/lib/src/block_syntaxes/alert_block_syntax.dart index be28ca93..54286040 100644 --- a/lib/src/block_syntaxes/alert_block_syntax.dart +++ b/lib/src/block_syntaxes/alert_block_syntax.dart @@ -26,8 +26,9 @@ class AlertBlockSyntax extends BlockSyntax { } /// Whether this alert ends with a lazy continuation line. - // The definition of lazy continuation lines: - // https://spec.commonmark.org/0.30/#lazy-continuation-line + /// + /// The definition of lazy continuation lines: + /// https://spec.commonmark.org/0.30/#lazy-continuation-line static bool _lazyContinuation = false; static final _contentLineRegExp = RegExp(r'>?\s?(.*)*'); @@ -40,7 +41,9 @@ class AlertBlockSyntax extends BlockSyntax { while (!parser.isDone) { final strippedContent = parser.current.content.replaceFirst(RegExp(r'^\s*>?\s*'), ''); - final match = _contentLineRegExp.firstMatch(strippedContent); + final match = strippedContent.isEmpty + ? null + : _contentLineRegExp.firstMatch(strippedContent); if (match != null) { childLines.add(Line(strippedContent)); parser.advance(); @@ -100,7 +103,7 @@ class AlertBlockSyntax extends BlockSyntax { final titleText = typeTextMap[type]!; final titleElement = Element('p', [Text(titleText)]) ..attributes['class'] = 'markdown-alert-title'; - final elementClass = 'markdown-alert markdown-alert-${type.toLowerCase()}'; + final elementClass = 'markdown-alert markdown-alert-$type'; return Element('div', [titleElement, ...children]) ..attributes['class'] = elementClass; } diff --git a/lib/src/version.dart b/lib/src/version.dart index 89858dde..b7a948d1 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '7.2.0'; +const packageVersion = '7.2.1'; diff --git a/pubspec.yaml b/pubspec.yaml index 5bab4d6a..90dfea31 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: markdown -version: 7.2.0 +version: 7.2.1 description: >- A portable Markdown library written in Dart that can parse Markdown into HTML. diff --git a/test/extensions/alert_extension.unit b/test/extensions/alert_extension.unit index c2a3da10..0f422b5c 100644 --- a/test/extensions/alert_extension.unit +++ b/test/extensions/alert_extension.unit @@ -74,7 +74,7 @@ Test note alert x2.

[!NOTE] Test blockquote.

->>>nested blockquote +>>> nested blockquote > [!NOTE] >> Test nested blockquote. <<< @@ -84,7 +84,7 @@ Test blockquote.

Test nested blockquote.

->>>escape brackets +>>> escape brackets > \[!note\] > Test escape brackets. <<< @@ -92,3 +92,40 @@ Test blockquote.

Note

Test escape brackets.

+>>> terminates properly +> [!note] +> A sample note. + +Additional markdown text. +<<< +
+

Note

+

A sample note.

+
+

Additional markdown text.

+>>> supports multiple quoted lines +> [!note] +> A sample note +> with two lines. + +Additional markdown text. +<<< +
+

Note

+

A sample note +with two lines.

+
+

Additional markdown text.

+>>> supports multiple lines +> [!note] +> A sample note + with two lines. + +Additional markdown text. +<<< +
+

Note

+

A sample note +with two lines.

+
+

Additional markdown text.