xref: /dokuwiki/inc/Parsing/ParserMode/Unformatted.php (revision 504c13e8df88563c11b3720b317991bc38835a35)
1<?php
2
3namespace dokuwiki\Parsing\ParserMode;
4
5use dokuwiki\Parsing\Handler;
6
7class Unformatted extends AbstractMode
8{
9    /** @inheritdoc */
10    public function getSort()
11    {
12        return 170;
13    }
14
15    /** @inheritdoc */
16    public function connectTo($mode)
17    {
18        $this->Lexer->addEntryPattern('<nowiki>(?=.*</nowiki>)', $mode, 'unformatted');
19        $this->Lexer->addEntryPattern('%%(?=.*%%)', $mode, 'unformattedalt');
20    }
21
22    /** @inheritdoc */
23    public function postConnect()
24    {
25        $this->Lexer->addExitPattern('</nowiki>', 'unformatted');
26        $this->Lexer->addExitPattern('%%', 'unformattedalt');
27        $this->Lexer->mapHandler('unformattedalt', 'unformatted');
28    }
29
30    /** @inheritdoc */
31    public function handle($match, $state, $pos, Handler $handler)
32    {
33        if ($state == DOKU_LEXER_UNMATCHED) {
34            $handler->addCall('unformatted', [$match], $pos);
35        }
36        return true;
37    }
38}
39