xref: /dokuwiki/inc/Parsing/Handler/Lists.php (revision bf6e4f0d2bea6ff572294f3280faef71d44e0917)
1<?php
2
3namespace dokuwiki\Parsing\Handler;
4
5/**
6 * CallWriter rewriter for DokuWiki lists.
7 *
8 * DokuWiki's list syntax requires 2 spaces of indent per nesting level and
9 * uses `*` for unordered, `-` for ordered. Ordered lists do not carry a
10 * start number. The state machine lives in {@see AbstractListsRewriter};
11 * this class supplies only the marker parser.
12 */
13class Lists extends AbstractListsRewriter
14{
15    /** @inheritdoc */
16    protected function interpretSyntax(string $match): array
17    {
18        $type = str_ends_with($match, '*') ? 'u' : 'o';
19        $depth = substr_count(str_replace("\t", '  ', $match), '  ') + 1;
20        return ['depth' => $depth, 'type' => $type];
21    }
22}
23