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

Implement IndentedCode

This commit is contained in:
Aidan Woods
2019-01-20 02:29:40 +00:00
parent ee094cb397
commit 565c8dd3cc
2 changed files with 81 additions and 46 deletions

View File

@ -288,52 +288,6 @@ class Parsedown
return \method_exists($this, 'block' . $Type . 'Complete');
}
#
# Code
protected function blockCode(Context $Context, $Block = null)
{
if (isset($Block) and $Block['type'] === 'Paragraph' and ! $Context->previousEmptyLines() > 0) {
return;
}
if ($Context->line()->indent() >= 4) {
$Block = [
'element' => [
'name' => 'pre',
'element' => [
'name' => 'code',
'text' => $Context->line()->ltrimBodyUpto(4),
],
],
];
return $Block;
}
}
protected function blockCodeContinue(Context $Context, $Block)
{
if ($Context->line()->indent() >= 4) {
if ($Context->previousEmptyLines() > 0) {
$Block['element']['element']['text'] .= \str_repeat("\n", $Context->previousEmptyLines());
unset($Block['interrupted']);
}
$Block['element']['element']['text'] .= "\n";
$Block['element']['element']['text'] .= $Context->line()->ltrimBodyUpto(4);
return $Block;
}
}
protected function blockCodeComplete($Block)
{
return $Block;
}
#
# Reference