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