Fix a blockquote issue (dart-lang/markdown#496)
Fix https://github.com/dart-lang/markdown/issues/495
diff --git a/pkgs/markdown/lib/src/block_syntaxes/blockquote_syntax.dart b/pkgs/markdown/lib/src/block_syntaxes/blockquote_syntax.dart
index 813cb2d..62f1903 100644
--- a/pkgs/markdown/lib/src/block_syntaxes/blockquote_syntax.dart
+++ b/pkgs/markdown/lib/src/block_syntaxes/blockquote_syntax.dart
@@ -33,8 +33,13 @@
final markerStart = match.match.indexOf('>');
int markerEnd;
if (currentLine.length > 1) {
- final nextChar = currentLine.codeUnitAt(markerStart + 1);
- final hasSpace = nextChar == $tab || nextChar == $space;
+ var hasSpace = false;
+ // Check if there is a following space if the marker is not at the end
+ // of this line.
+ if (markerStart < currentLine.length - 1) {
+ final nextChar = currentLine.codeUnitAt(markerStart + 1);
+ hasSpace = nextChar == $tab || nextChar == $space;
+ }
markerEnd = markerStart + (hasSpace ? 2 : 1);
} else {
markerEnd = markerStart + 1;
diff --git a/pkgs/markdown/test/original/block_quotes.unit b/pkgs/markdown/test/original/block_quotes.unit
index ac20218..548bc1a 100644
--- a/pkgs/markdown/test/original/block_quotes.unit
+++ b/pkgs/markdown/test/original/block_quotes.unit
@@ -47,3 +47,8 @@
<p>quote</p>
</blockquote>
<hr />
+>>> issue #495
+ >
+<<<
+<blockquote>
+</blockquote>