address a termination issue with GitHub alert syntax parsing (dart-lang/markdown#576)
address a termination issue with GitHub alert syntax parsing
diff --git a/pkgs/markdown/CHANGELOG.md b/pkgs/markdown/CHANGELOG.md
index ee08de9..42073b7 100644
--- a/pkgs/markdown/CHANGELOG.md
+++ b/pkgs/markdown/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/pkgs/markdown/lib/src/block_syntaxes/alert_block_syntax.dart b/pkgs/markdown/lib/src/block_syntaxes/alert_block_syntax.dart
index be28ca9..5428604 100644
--- a/pkgs/markdown/lib/src/block_syntaxes/alert_block_syntax.dart
+++ b/pkgs/markdown/lib/src/block_syntaxes/alert_block_syntax.dart
@@ -26,8 +26,9 @@
}
/// 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 @@
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 @@
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/pkgs/markdown/lib/src/version.dart b/pkgs/markdown/lib/src/version.dart
index 89858dd..b7a948d 100644
--- a/pkgs/markdown/lib/src/version.dart
+++ b/pkgs/markdown/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/pkgs/markdown/pubspec.yaml b/pkgs/markdown/pubspec.yaml
index 5bab4d6..90dfea3 100644
--- a/pkgs/markdown/pubspec.yaml
+++ b/pkgs/markdown/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/pkgs/markdown/test/extensions/alert_extension.unit b/pkgs/markdown/test/extensions/alert_extension.unit
index c2a3da1..0f422b5 100644
--- a/pkgs/markdown/test/extensions/alert_extension.unit
+++ b/pkgs/markdown/test/extensions/alert_extension.unit
@@ -74,7 +74,7 @@
<p>[!NOTE]
Test blockquote.</p>
</blockquote>
->>>nested blockquote
+>>> nested blockquote
> [!NOTE]
>> Test nested blockquote.
<<<
@@ -84,7 +84,7 @@
<p>Test nested blockquote.</p>
</blockquote>
</div>
->>>escape brackets
+>>> escape brackets
> \[!note\]
> Test escape brackets.
<<<
@@ -92,3 +92,40 @@
<p class="markdown-alert-title">Note</p>
<p>Test escape brackets.</p>
</div>
+>>> terminates properly
+> [!note]
+> A sample note.
+
+Additional markdown text.
+<<<
+<div class="markdown-alert markdown-alert-note">
+<p class="markdown-alert-title">Note</p>
+<p>A sample note.</p>
+</div>
+<p>Additional markdown text.</p>
+>>> supports multiple quoted lines
+> [!note]
+> A sample note
+> with two lines.
+
+Additional markdown text.
+<<<
+<div class="markdown-alert markdown-alert-note">
+<p class="markdown-alert-title">Note</p>
+<p>A sample note
+with two lines.</p>
+</div>
+<p>Additional markdown text.</p>
+>>> supports multiple lines
+> [!note]
+> A sample note
+ with two lines.
+
+Additional markdown text.
+<<<
+<div class="markdown-alert markdown-alert-note">
+<p class="markdown-alert-title">Note</p>
+<p>A sample note
+with two lines.</p>
+</div>
+<p>Additional markdown text.</p>