= $current; $x--) {
if ($x !== $i - 1 && !isset($caption[$x + 1])) {
unset($caption[$x]);
}
}
} else {
$endcap = null;
$caption = [];
}
$block = [
'figure',
'endcap' => $endcap,
'content' => $this->parseBlocks($content),
'caption' => $this->parseBlocks(array_values($caption)),
];
return [$block, $i];
}
/**
* Renders a figure.
*/
protected function renderFigure($block): string
{
$caption = $block['endcap'] === null ?
'' :
"\n"
. $this->renderAbsy($block['caption'])
. "\n" ;
if ($block['endcap'] === false) {
$figure = "\n";
} else {
$figure = "\n";
}
return $figure;
}
abstract protected function parseBlocks($lines);
abstract protected function renderAbsy($absy);
}