xref: /dokuwiki/inc/Parsing/ParserMode/Listblock.php (revision c8dd1b9d24a2f9905db764a0ac4646fb1e172af4)
1be906b56SAndreas Gohr<?php
2be906b56SAndreas Gohr
3be906b56SAndreas Gohrnamespace dokuwiki\Parsing\ParserMode;
4be906b56SAndreas Gohr
5*c8dd1b9dSAndreas Gohruse dokuwiki\Parsing\ModeRegistry;
6*c8dd1b9dSAndreas Gohr
7be906b56SAndreas Gohrclass Listblock extends AbstractMode
8be906b56SAndreas Gohr{
9be906b56SAndreas Gohr    /**
10be906b56SAndreas Gohr     * Listblock constructor.
11be906b56SAndreas Gohr     */
12be906b56SAndreas Gohr    public function __construct()
13be906b56SAndreas Gohr    {
14*c8dd1b9dSAndreas Gohr        $this->allowedModes = ModeRegistry::getInstance()->getModesForCategories([
15*c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_FORMATTING,
16*c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_SUBSTITION,
17*c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_DISABLED,
18*c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_PROTECTED,
19*c8dd1b9dSAndreas Gohr        ]);
20be906b56SAndreas Gohr    }
21be906b56SAndreas Gohr
22be906b56SAndreas Gohr    /** @inheritdoc */
23be906b56SAndreas Gohr    public function connectTo($mode)
24be906b56SAndreas Gohr    {
25be906b56SAndreas Gohr        $this->Lexer->addEntryPattern('[ \t]*\n {2,}[\-\*]', $mode, 'listblock');
26be906b56SAndreas Gohr        $this->Lexer->addEntryPattern('[ \t]*\n\t{1,}[\-\*]', $mode, 'listblock');
27be906b56SAndreas Gohr
28be906b56SAndreas Gohr        $this->Lexer->addPattern('\n {2,}[\-\*]', 'listblock');
29be906b56SAndreas Gohr        $this->Lexer->addPattern('\n\t{1,}[\-\*]', 'listblock');
30be906b56SAndreas Gohr    }
31be906b56SAndreas Gohr
32be906b56SAndreas Gohr    /** @inheritdoc */
33be906b56SAndreas Gohr    public function postConnect()
34be906b56SAndreas Gohr    {
35be906b56SAndreas Gohr        $this->Lexer->addExitPattern('\n', 'listblock');
36be906b56SAndreas Gohr    }
37be906b56SAndreas Gohr
38be906b56SAndreas Gohr    /** @inheritdoc */
39be906b56SAndreas Gohr    public function getSort()
40be906b56SAndreas Gohr    {
41be906b56SAndreas Gohr        return 10;
42be906b56SAndreas Gohr    }
43be906b56SAndreas Gohr}
44