1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

code block doesn't have to use regex

This commit is contained in:
Emanuil Rusev 2014-01-16 23:43:12 +02:00
parent 5dd0e8cb7b
commit 408cb5c21f

View File

@ -272,8 +272,10 @@ class Parsedown
# code block
if (preg_match('/^[ ]{4}(.*)/', $line, $matches))
if (isset($line[3]) and $line[3] === ' ' and $line[2] === ' ' and $line[1] === ' ')
{
$code_line = substr($line, 4);
if ($element['type'] === 'code block')
{
if (isset($element['interrupted']))
@ -283,7 +285,7 @@ class Parsedown
unset ($element['interrupted']);
}
$element['text'] .= "\n".$matches[1];
$element['text'] .= "\n".$code_line;
}
else
{
@ -291,7 +293,7 @@ class Parsedown
$element = array(
'type' => 'code block',
'text' => $matches[1],
'text' => $code_line,
);
}