xref: /dokuwiki/inc/Parsing/ParserMode/Footnote.php (revision d4f83172d9533c4d84f450fe22ef630816b21d75)
1*be906b56SAndreas Gohr<?php
2*be906b56SAndreas Gohr
3*be906b56SAndreas Gohrnamespace dokuwiki\Parsing\ParserMode;
4*be906b56SAndreas Gohr
5*be906b56SAndreas Gohrclass Footnote extends AbstractMode
6*be906b56SAndreas Gohr{
7*be906b56SAndreas Gohr    /**
8*be906b56SAndreas Gohr     * Footnote 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['container'],
16*be906b56SAndreas Gohr            $PARSER_MODES['formatting'],
17*be906b56SAndreas Gohr            $PARSER_MODES['substition'],
18*be906b56SAndreas Gohr            $PARSER_MODES['protected'],
19*be906b56SAndreas Gohr            $PARSER_MODES['disabled']
20*be906b56SAndreas Gohr        );
21*be906b56SAndreas Gohr
22*be906b56SAndreas Gohr        unset($this->allowedModes[array_search('footnote', $this->allowedModes)]);
23*be906b56SAndreas Gohr    }
24*be906b56SAndreas Gohr
25*be906b56SAndreas Gohr    /** @inheritdoc */
26*be906b56SAndreas Gohr    public function connectTo($mode)
27*be906b56SAndreas Gohr    {
28*be906b56SAndreas Gohr        $this->Lexer->addEntryPattern(
29*be906b56SAndreas Gohr            '\x28\x28(?=.*\x29\x29)',
30*be906b56SAndreas Gohr            $mode,
31*be906b56SAndreas Gohr            'footnote'
32*be906b56SAndreas Gohr        );
33*be906b56SAndreas Gohr    }
34*be906b56SAndreas Gohr
35*be906b56SAndreas Gohr    /** @inheritdoc */
36*be906b56SAndreas Gohr    public function postConnect()
37*be906b56SAndreas Gohr    {
38*be906b56SAndreas Gohr        $this->Lexer->addExitPattern(
39*be906b56SAndreas Gohr            '\x29\x29',
40*be906b56SAndreas Gohr            'footnote'
41*be906b56SAndreas Gohr        );
42*be906b56SAndreas Gohr    }
43*be906b56SAndreas Gohr
44*be906b56SAndreas Gohr    /** @inheritdoc */
45*be906b56SAndreas Gohr    public function getSort()
46*be906b56SAndreas Gohr    {
47*be906b56SAndreas Gohr        return 150;
48*be906b56SAndreas Gohr    }
49*be906b56SAndreas Gohr}
50