xref: /dokuwiki/inc/Parsing/ParserMode/Quotes.php (revision d4f83172d9533c4d84f450fe22ef630816b21d75)
1*be906b56SAndreas Gohr<?php
2*be906b56SAndreas Gohr
3*be906b56SAndreas Gohrnamespace dokuwiki\Parsing\ParserMode;
4*be906b56SAndreas Gohr
5*be906b56SAndreas Gohrclass Quotes extends AbstractMode
6*be906b56SAndreas Gohr{
7*be906b56SAndreas Gohr    /** @inheritdoc */
8*be906b56SAndreas Gohr    public function connectTo($mode)
9*be906b56SAndreas Gohr    {
10*be906b56SAndreas Gohr        global $conf;
11*be906b56SAndreas Gohr
12*be906b56SAndreas Gohr        $ws   =  '\s/\#~:+=&%@\-\x28\x29\]\[{}><"\'';   // whitespace
13*be906b56SAndreas Gohr        $punc =  ';,\.?!';
14*be906b56SAndreas Gohr
15*be906b56SAndreas Gohr        if ($conf['typography'] == 2) {
16*be906b56SAndreas Gohr            $this->Lexer->addSpecialPattern(
17*be906b56SAndreas Gohr                "(?<=^|[$ws])'(?=[^$ws$punc])",
18*be906b56SAndreas Gohr                $mode,
19*be906b56SAndreas Gohr                'singlequoteopening'
20*be906b56SAndreas Gohr            );
21*be906b56SAndreas Gohr            $this->Lexer->addSpecialPattern(
22*be906b56SAndreas Gohr                "(?<=^|[^$ws]|[$punc])'(?=$|[$ws$punc])",
23*be906b56SAndreas Gohr                $mode,
24*be906b56SAndreas Gohr                'singlequoteclosing'
25*be906b56SAndreas Gohr            );
26*be906b56SAndreas Gohr            $this->Lexer->addSpecialPattern(
27*be906b56SAndreas Gohr                "(?<=^|[^$ws$punc])'(?=$|[^$ws$punc])",
28*be906b56SAndreas Gohr                $mode,
29*be906b56SAndreas Gohr                'apostrophe'
30*be906b56SAndreas Gohr            );
31*be906b56SAndreas Gohr        }
32*be906b56SAndreas Gohr
33*be906b56SAndreas Gohr        $this->Lexer->addSpecialPattern(
34*be906b56SAndreas Gohr            "(?<=^|[$ws])\"(?=[^$ws$punc])",
35*be906b56SAndreas Gohr            $mode,
36*be906b56SAndreas Gohr            'doublequoteopening'
37*be906b56SAndreas Gohr        );
38*be906b56SAndreas Gohr        $this->Lexer->addSpecialPattern(
39*be906b56SAndreas Gohr            "\"",
40*be906b56SAndreas Gohr            $mode,
41*be906b56SAndreas Gohr            'doublequoteclosing'
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 280;
49*be906b56SAndreas Gohr    }
50*be906b56SAndreas Gohr}
51