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