aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Parsing/ParserMode/Filelink.php
blob: 3e57af32f981c3c0ae69b31ba09b525a76285c13 (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
<?php

namespace dokuwiki\Parsing\ParserMode;

class Filelink extends AbstractMode
{
    protected $pattern;

    /** @inheritdoc */
    public function preConnect()
    {

        $ltrs = '\w';
        $gunk = '/\#~:.?+=&%@!\-';
        $punc = '.:?\-;,';
        $any  = $ltrs . $gunk . $punc;

        $this->pattern = '\b(?i)file(?-i)://[' . $any . ']+?[' .
            $punc . ']*[^' . $any . ']';
    }

    /** @inheritdoc */
    public function connectTo($mode)
    {
        $this->Lexer->addSpecialPattern(
            $this->pattern,
            $mode,
            'filelink'
        );
    }

    /** @inheritdoc */
    public function getSort()
    {
        return 360;
    }
}