From c154f45386b371157e435b234bfc54140a2f1587 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 13 Jun 2021 10:52:44 -0700 Subject: [PATCH] Markdown: allow backticks-delimited code blocks in lists Using backticks-delimited code blocks in lists has apparently become rather widely used even though the original specification didn't seem to allow them within lists. Make the needed changes to allow this. The changes are actually rather minor. And do update the syntax document to reflect this change. Signed-off-by: Kyle J. McKay --- Markdown.pl | 13 +++++++++---- syntax.md | 4 ---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Markdown.pl b/Markdown.pl index 6336bc8..66098f2 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -1472,8 +1472,8 @@ sub _HashBTCodeBlocks { $codeblock = "
"
 		. $codeblock . "\n
"; - my $key = block_id($codeblock); - $g_html_blocks{$key} = $codeblock; + my $key = block_id($codeblock, 2); + $g_code_blocks{$key} = $codeblock; "\n\n" . $key . "\n\n"; }egmx; @@ -1768,6 +1768,11 @@ sub _RunBlockGamut { } +sub _DoBTListBlocks { + return _DoBlockQuotes(_DoCodeBlocks(_HashBTCodeBlocks($_[0]))) if $_[0] ne ""; +} + + sub _DoListBlocks { return _DoBlockQuotes(_DoCodeBlocks($_[0])) if $_[0] ne ""; } @@ -2776,11 +2781,11 @@ sub _DoListsAndBlocks { while ($parse =~ /\G(?s:.)*?^$whole_list/gmc) { my @captures = ($1, $2, $3, $4); if ($-[1] > $-[0]) { - $text .= _DoListBlocks(substr($parse, $-[0], $-[1] - $-[0])); + $text .= _DoBTListBlocks(substr($parse, $-[0], $-[1] - $-[0])); } $text .= &$list_item_sub(@captures); } - $text .= _DoListBlocks(substr($parse, pos($parse))) if pos($parse) < length($parse); + $text .= _DoBTListBlocks(substr($parse, pos($parse))) if pos($parse) < length($parse); } else { my $parse = $text; diff --git a/syntax.md b/syntax.md index cab9073..2856293 100644 --- a/syntax.md +++ b/syntax.md @@ -769,10 +769,6 @@ A code block continues until it reaches a line that is not indented until a line consisting of the same number of backtick quotes is found when using the 3 backtick quotes technique. -Note that the 3 backtick quotes (or more) must appear at the beginning -of the line. To include a code block within a list (or other indented -element), the indentation technique must be used. - Also note that within a backticks-delimited code block, tab characters are always expanded with the tab stop locations 8 characters apart.