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