Browse Source

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 <mackyle@gmail.com>
master
Kyle J. McKay 3 years ago
parent
commit
c154f45386
  1. 13
      Markdown.pl
  2. 4
      syntax.md

13
Markdown.pl

@ -1472,8 +1472,8 @@ sub _HashBTCodeBlocks {
$codeblock = "<div class=\"$opt{style_prefix}code-bt\"><pre style=\"display:none\"></pre><pre><code>"
. $codeblock . "\n</code></pre></div>";
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;

4
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.

Loading…
Cancel
Save