in src/render/MarkdownRenderer.php [126:202]
protected function renderListItem(
int $list_count,
Blocks\ListOfItems $list,
Blocks\ListItem $item,
): string {
$num = $list->getFirstNumber();
if ($num === null) {
/* This is a single loose list:
*
* - foo
* - bar
*
* - baz
*
* This is two tight lists:
*
* - foo
* - bar
*
* + baz
*/
$seps = vec['-', '+', '*'];
$sep = $seps[$list_count % 3].' ';
} else {
/* One loose list:
*
* 1. foo
* 2. bar
*
* 3. baz
*
* Two tight lists:
*
* 1. foo
* 2. bar
* 3) baz
*/
$seps = vec['.', ')'];
$sep = $num.$seps[$list_count % 2].' ';
}
$leading = Str\length($sep);
if ($item is Blocks\TaskListItemExtension) {
$sep .= \sprintf('[%s] ', $item->isChecked() ? 'x' : ' ');
}
if ($list->isLoose()) {
$content = $item->getChildren()
|> $this->renderNodes($$)
|> $$."\n";
} else {
$content = $item->getChildren()
|> Vec\map(
$$,
$child ==> {
if ($child is Blocks\Paragraph) {
return $this->renderNodes($child->getContents());
}
if ($child is Blocks\Block) {
return Str\trim($this->render($child));
}
return $this->render($child);
},
)
|> Str\join($$, "\n");
}
return $content
|> Str\split($$, "\n")
|> Vec\map(
$$,
$line ==> ($line === '') ? $line : (Str\repeat(' ', $leading).$line),
)
|> Str\join($$, "\n")
|> Str\slice($$, Math\minva(Str\length($$), $leading))
|> $sep.$$;
}