xref: /dokuwiki/inc/Parsing/ParserMode/Footnote.php (revision be906b566b9bdfd92c032ee07c4fd077d820a8d1)
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    /**
9*be906b56SAndreas Gohr     * Footnote constructor.
10*be906b56SAndreas Gohr     */
11*be906b56SAndreas Gohr    public function __construct()
12*be906b56SAndreas Gohr    {
13*be906b56SAndreas Gohr        global $PARSER_MODES;
14*be906b56SAndreas Gohr
15*be906b56SAndreas Gohr        $this->allowedModes = array_merge(
16*be906b56SAndreas Gohr            $PARSER_MODES['container'],
17*be906b56SAndreas Gohr            $PARSER_MODES['formatting'],
18*be906b56SAndreas Gohr            $PARSER_MODES['substition'],
19*be906b56SAndreas Gohr            $PARSER_MODES['protected'],
20*be906b56SAndreas Gohr            $PARSER_MODES['disabled']
21*be906b56SAndreas Gohr        );
22*be906b56SAndreas Gohr
23*be906b56SAndreas Gohr        unset($this->allowedModes[array_search('footnote', $this->allowedModes)]);
24*be906b56SAndreas Gohr    }
25*be906b56SAndreas Gohr
26*be906b56SAndreas Gohr    /** @inheritdoc */
27*be906b56SAndreas Gohr    public function connectTo($mode)
28*be906b56SAndreas Gohr    {
29*be906b56SAndreas Gohr        $this->Lexer->addEntryPattern(
30*be906b56SAndreas Gohr            '\x28\x28(?=.*\x29\x29)',
31*be906b56SAndreas Gohr            $mode,
32*be906b56SAndreas Gohr            'footnote'
33*be906b56SAndreas Gohr        );
34*be906b56SAndreas Gohr    }
35*be906b56SAndreas Gohr
36*be906b56SAndreas Gohr    /** @inheritdoc */
37*be906b56SAndreas Gohr    public function postConnect()
38*be906b56SAndreas Gohr    {
39*be906b56SAndreas Gohr        $this->Lexer->addExitPattern(
40*be906b56SAndreas Gohr            '\x29\x29',
41*be906b56SAndreas Gohr            'footnote'
42*be906b56SAndreas Gohr        );
43*be906b56SAndreas Gohr    }
44*be906b56SAndreas Gohr
45*be906b56SAndreas Gohr    /** @inheritdoc */
46*be906b56SAndreas Gohr    public function getSort()
47*be906b56SAndreas Gohr    {
48*be906b56SAndreas Gohr        return 150;
49*be906b56SAndreas Gohr    }
50*be906b56SAndreas Gohr}
51