From b0ea7deb5074c0c936aad5106e19ebe8a07226ee Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Fri, 15 Nov 2019 04:03:59 -0700 Subject: [PATCH] Markdown.pl: do not start a list with a single year or initial Avoid starting a new list when seeing only one single orphan list item that appears to be either a year or an initial (only UPPERCASE though). Signed-off-by: Kyle J. McKay --- Markdown.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Markdown.pl b/Markdown.pl index 7c8c6e3..ce15449 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -1630,6 +1630,7 @@ sub _DoLists { # paragraph for the last item in a list, if necessary: $list =~ s/\n\n/\n\n\n/g; my ($result, $first_marker, $fancy) = _ProcessListItems($list_type, $list); + defined($first_marker) or return $list; my $list_marker_type = _GetListMarkerType($list_type, $first_marker); if ($list_marker_type) { $first_marker =~ s/[.\)]$//; @@ -1887,6 +1888,18 @@ sub _ProcessListItems { $result .= _RunBlockGamut(substr($list_str, pos($list_str))); $g_list_level--; + + # After all that, if we only got an ordered list with a single item + # and its first marker is a four-digit number >= 1492 and <= 2999 + # or an UPPERCASE letter, then pretend we didn't see any list at all. + + if ($first_marker_type && $first_marker_num + 1 == $next_num) { + if (($first_marker_type eq "1" && $first_marker_num >= 1492 && $first_marker_num <= 2999) || + ($first_marker_type eq "A" && !$fancy)) { + return (undef, undef, undef); + } + } + return ($result, $first_marker, $fancy); }