xref: /dokuwiki/inc/Parsing/ParserMode/Filelink.php (revision 90fb952c4c30c09c8446076ba05991c89a3f0b01)
1<?php
2
3namespace dokuwiki\Parsing\ParserMode;
4
5class Filelink extends AbstractMode
6{
7
8    protected $pattern;
9
10    /** @inheritdoc */
11    public function preConnect()
12    {
13
14        $ltrs = '\w';
15        $gunk = '/\#~:.?+=&%@!\-';
16        $punc = '.:?\-;,';
17        $any  = $ltrs . $gunk . $punc;
18
19        $this->pattern = '\b(?i)file(?-i)://[' . $any . ']+?[' .
20            $punc . ']*[^' . $any . ']';
21    }
22
23    /** @inheritdoc */
24    public function connectTo($mode)
25    {
26        $this->Lexer->addSpecialPattern(
27            $this->pattern,
28            $mode,
29            'filelink'
30        );
31    }
32
33    /** @inheritdoc */
34    public function getSort()
35    {
36        return 360;
37    }
38}
39