From 509770c74352a76a95e20f3373a27c6678793cf6 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 14 Jun 2021 14:31:31 -0700 Subject: [PATCH] Markdown.pl: do not start sublist in list marker line Given a list like so: * 1. item * 2. items * 3. items Each line contains two list item "markers". The first is an unordered list marker "*" and the second is an ordered list marker ("1.", "2." or "3."). However, a sublist (the "1.", "2." or "3.") may not start inside the actual marker line of the parent list. Make sure that any text on the same line following the initial list marker does *not* get recognized as the start of a sublist. In other words, make sure the above does _NOT_ produce: But instead more correctly produces this output: Recognizing a sublist start within any of the parent list's marker lines does not make sense. With this change this longstanding problem is corrected once again. The problem was first fixed in version 1.1.0 and remained fixed in version 1.1.1 but that fix caused too many problems and was reverted causing versions 1.1.2 through 1.1.13 to be broken again. The technique used to fix the problem this time differs from the previous attempt and will hopefully survive scrutiny keeping the problem resolved from now on. Signed-off-by: Kyle J. McKay --- Markdown.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Markdown.pl b/Markdown.pl index 666a0c9..e742c64 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -2972,6 +2972,13 @@ sub _ProcessListItems { } $last_marker = $list_marker; + if ($item =~ /^(.+)/) { + my $ml_text = $1; + my $ml_len = length($1); + my $ml_sub = sub {my $ml_mk = shift; $ml_mk =~ s!([-+*.\)])!$g_escape_table{$1}!go; $ml_mk}; + $ml_text =~ s/(?:(?<= )|\A)(${marker_any})(?= )/&$ml_sub($1)/ge; + $item = $ml_text . substr($item, $ml_len); + } if ($leading_line or ($item =~ m/\n{2,}/)) { $item = _RunBlockGamut(_Outdent($item)); $item =~ s{()\s*\z}{$1} and $item .= "\n$idt ";