mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 03:51:29 +02:00
code block doesn't have to use regex
This commit is contained in:
parent
5dd0e8cb7b
commit
408cb5c21f
@ -272,8 +272,10 @@ class Parsedown
|
|||||||
|
|
||||||
# code block
|
# 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 ($element['type'] === 'code block')
|
||||||
{
|
{
|
||||||
if (isset($element['interrupted']))
|
if (isset($element['interrupted']))
|
||||||
@ -283,7 +285,7 @@ class Parsedown
|
|||||||
unset ($element['interrupted']);
|
unset ($element['interrupted']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$element['text'] .= "\n".$matches[1];
|
$element['text'] .= "\n".$code_line;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -291,7 +293,7 @@ class Parsedown
|
|||||||
|
|
||||||
$element = array(
|
$element = array(
|
||||||
'type' => 'code block',
|
'type' => 'code block',
|
||||||
'text' => $matches[1],
|
'text' => $code_line,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user