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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 7.2.1

* Address a termination issue with GitHub alert syntax parsing.

## 7.2.0

* Require Dart `^3.1.0`.
Expand Down
11 changes: 7 additions & 4 deletions lib/src/block_syntaxes/alert_block_syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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?(.*)*');

Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
41 changes: 39 additions & 2 deletions test/extensions/alert_extension.unit
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Test note alert x2.</p>
<p>[!NOTE]
Test blockquote.</p>
</blockquote>
>>>nested blockquote
>>> nested blockquote
> [!NOTE]
>> Test nested blockquote.
<<<
Expand All @@ -84,11 +84,48 @@ Test blockquote.</p>
<p>Test nested blockquote.</p>
</blockquote>
</div>
>>>escape brackets
>>> escape brackets
> \[!note\]
> Test escape brackets.
<<<
<div class="markdown-alert markdown-alert-note">
<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>