in src/unparsed-blocks/FencedBlock.php [15:66]
protected abstract static function createFromLines(
vec<string> $lines,
int $indentation_of_first,
bool $eof,
): this;
protected abstract static function getEndPatternForFirstLine(
Context $context,
int $column,
string $first,
): ?string;
public static function consume(
Context $context,
Lines $lines,
): ?(this, Lines) {
list($indentation, $first, $rest) = $lines->getColumnFirstLineAndRest();
$end = static::getEndPatternForFirstLine($context, $indentation, $first);
if ($end === null) {
return null;
}
$matched = vec[$first];
if (
\is_a(static::class, HTMLBlock::class, true)
&& \preg_match($end, $first) === 1
) {
// Keyed specifically to HTMLBlock as the behavior for the rest of the
// line feels a bit strange
return tuple(
static::createFromLines($matched, $indentation, false),
$rest,
);
}
$eof = true;
while (!$rest->isEmpty()) {
list($line, $rest) = $rest->getFirstLineAndRest();
$matched[] = $line;
if (\preg_match($end, $line) === 1) {
$eof = false;
break;
}
}
return tuple(
static::createFromLines($matched, $indentation, $eof),
$rest,
);
}