1<?php
2
3namespace dokuwiki\Parsing\ParserMode;
4
5class Table extends AbstractMode
6{
7    /**
8     * Table constructor.
9     */
10    public function __construct()
11    {
12        global $PARSER_MODES;
13
14        $this->allowedModes = array_merge(
15            $PARSER_MODES['formatting'],
16            $PARSER_MODES['substition'],
17            $PARSER_MODES['disabled'],
18            $PARSER_MODES['protected']
19        );
20    }
21
22    /** @inheritdoc */
23    public function connectTo($mode)
24    {
25        $this->Lexer->addEntryPattern('[\t ]*\n\^', $mode, 'table');
26        $this->Lexer->addEntryPattern('[\t ]*\n\|', $mode, 'table');
27    }
28
29    /** @inheritdoc */
30    public function postConnect()
31    {
32        $this->Lexer->addPattern('\n\^', 'table');
33        $this->Lexer->addPattern('\n\|', 'table');
34        $this->Lexer->addPattern('[\t ]*:::[\t ]*(?=[\|\^])', 'table');
35        $this->Lexer->addPattern('[\t ]+', 'table');
36        $this->Lexer->addPattern('\^', 'table');
37        $this->Lexer->addPattern('\|', 'table');
38        $this->Lexer->addExitPattern('\n', 'table');
39    }
40
41    /** @inheritdoc */
42    public function getSort()
43    {
44        return 60;
45    }
46}
47