aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/parser/parser.php
blob: 225dee35b8b89d233d9021da1b8aeae841a41af9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php

use dokuwiki\Debug\PropertyDeprecationHelper;
use dokuwiki\Parsing\Parser;

/**
 * Define various types of modes used by the parser - they are used to
 * populate the list of modes another mode accepts
 */
global $PARSER_MODES;
$PARSER_MODES = [
    // containers are complex modes that can contain many other modes
    // hr breaks the principle but they shouldn't be used in tables / lists
    // so they are put here
    'container' => ['listblock', 'table', 'quote', 'hr'],
    // some mode are allowed inside the base mode only
    'baseonly' => ['header'],
    // modes for styling text -- footnote behaves similar to styling
    'formatting' => [
        'strong', 'emphasis', 'underline', 'monospace', 'subscript', 'superscript', 'deleted', 'footnote'
    ],
    // modes where the token is simply replaced - they can not contain any
    // other modes
    'substition' => [
        'acronym', 'smiley', 'wordblock', 'entity', 'camelcaselink', 'internallink', 'media', 'externallink',
        'linebreak', 'emaillink', 'windowssharelink', 'filelink', 'notoc', 'nocache', 'multiplyentity', 'quotes', 'rss'
    ],
    // modes which have a start and end token but inside which
    // no other modes should be applied
    'protected' => ['preformatted', 'code', 'file'],
    // inside this mode no wiki markup should be applied but lineendings
    // and whitespace isn't preserved
    'disabled' => ['unformatted'],
    // used to mark paragraph boundaries
    'paragraphs' => ['eol'],
];

/**
 * Class Doku_Parser
 *
 * @deprecated 2018-05-04
 */
class Doku_Parser extends Parser
{
    use PropertyDeprecationHelper {
        __set as protected deprecationHelperMagicSet;
        __get as protected deprecationHelperMagicGet;
    }

    /** @inheritdoc */
    public function __construct(Doku_Handler $handler = null)
    {
        dbg_deprecated(Parser::class);
        $this->deprecatePublicProperty('modes', self::class);
        $this->deprecatePublicProperty('connected', self::class);

        if (!$handler instanceof \Doku_Handler) {
            $handler = new Doku_Handler();
        }

        parent::__construct($handler);
    }

    public function __set($name, $value)
    {

        if ($name === 'Handler') {
            $this->handler = $value;
            return;
        }

        if ($name === 'Lexer') {
            $this->lexer = $value;
            return;
        }

        $this->deprecationHelperMagicSet($name, $value);
    }

    public function __get($name)
    {
        if ($name === 'Handler') {
            return $this->handler;
        }

        if ($name === 'Lexer') {
            return $this->lexer;
        }

        return $this->deprecationHelperMagicGet($name);
    }
}