Fix delimiter row matching pattern for tables (dart-lang/markdown#540)
diff --git a/pkgs/markdown/lib/src/patterns.dart b/pkgs/markdown/lib/src/patterns.dart index 68299ee..967434a 100644 --- a/pkgs/markdown/lib/src/patterns.dart +++ b/pkgs/markdown/lib/src/patterns.dart
@@ -48,7 +48,7 @@ /// A line of hyphens separated by at least one pipe. final tablePattern = RegExp( - r'^[ ]{0,3}\|?([ \t]*:?\-+:?[ \t]*\|)+([ \t]|[ \t]*:?\-+:?[ \t]*)?$'); + r'^[ ]{0,3}\|?([ \t]*:?\-+:?[ \t]*\|[ \t]*)+([ \t]|[ \t]*:?\-+:?[ \t]*)?$'); /// A line starting with `[^` and contains with `]:`, but without special chars /// (`\] \r\n\x00\t`) between. Same as [GFM](cmark-gfm/src/scanners.re:318).
diff --git a/pkgs/markdown/test/extensions/tables.unit b/pkgs/markdown/test/extensions/tables.unit index 482ef12..35b1a15 100644 --- a/pkgs/markdown/test/extensions/tables.unit +++ b/pkgs/markdown/test/extensions/tables.unit
@@ -336,3 +336,22 @@ <p>| A | <a href="url">B</a> | C | |---|---| | a | b | c |</p> +>>> trailing whitespace after delimiter row +| Name | Value | +| --- | --- | +| Foo | bar | +<<< +<table> +<thead> +<tr> +<th>Name</th> +<th>Value</th> +</tr> +</thead> +<tbody> +<tr> +<td>Foo</td> +<td>bar</td> +</tr> +</tbody> +</table>