in src/inlines/_Private/parse_with_blacklist.php [16:55]
function parse_with_denylist (
Inlines\Context $context,
string $markdown,
int $offset,
keyset<classname<Inlines\Inline>> $denylist,
): (vec<Inlines\Inline>, int) {
$types = $context->getInlineTypes();
foreach ($denylist as $type) {
unset($types[$type]);
}
$out = vec[];
$len = Str\length($markdown);
while ($offset < $len) {
$result = null;
foreach ($types as $type) {
$result = $type::consume($context, $markdown, $offset);
if ($result !== null) {
break;
}
}
if ($result === null) {
return tuple($out, $offset);
}
list($inline, $new_offset) = $result;
invariant(
$new_offset > $offset,
"Failed to consume any data with %s",
\get_class($inline),
);
$offset = $new_offset;
if ($inline is Inlines\InlineSequence) {
$out = Vec\concat($out, $inline->getChildren());
} else {
$out[] = $inline;
}
}
return tuple($out, $offset);
}