xref: /dokuwiki/inc/Parsing/ParserMode/Multiplyentity.php (revision 71096e46fcbfaeaa808667aba794e77fe2780169)
1be906b56SAndreas Gohr<?php
2be906b56SAndreas Gohr
3be906b56SAndreas Gohrnamespace dokuwiki\Parsing\ParserMode;
4be906b56SAndreas Gohr
5*71096e46SAndreas Gohruse dokuwiki\Parsing\Handler;
6*71096e46SAndreas Gohr
7be906b56SAndreas Gohr/**
8be906b56SAndreas Gohr * Implements the 640x480 replacement
9be906b56SAndreas Gohr */
10be906b56SAndreas Gohrclass Multiplyentity extends AbstractMode
11be906b56SAndreas Gohr{
12be906b56SAndreas Gohr    /** @inheritdoc */
13*71096e46SAndreas Gohr    public function getSort()
14*71096e46SAndreas Gohr    {
15*71096e46SAndreas Gohr        return 270;
16*71096e46SAndreas Gohr    }
17*71096e46SAndreas Gohr
18*71096e46SAndreas Gohr    /** @inheritdoc */
19be906b56SAndreas Gohr    public function connectTo($mode)
20be906b56SAndreas Gohr    {
21be906b56SAndreas Gohr
22be906b56SAndreas Gohr        $this->Lexer->addSpecialPattern(
23be906b56SAndreas Gohr            '(?<=\b)(?:[1-9]|\d{2,})[xX]\d+(?=\b)',
24be906b56SAndreas Gohr            $mode,
25be906b56SAndreas Gohr            'multiplyentity'
26be906b56SAndreas Gohr        );
27be906b56SAndreas Gohr    }
28be906b56SAndreas Gohr
29be906b56SAndreas Gohr    /** @inheritdoc */
30*71096e46SAndreas Gohr    public function handle($match, $state, $pos, Handler $handler)
31be906b56SAndreas Gohr    {
32*71096e46SAndreas Gohr        preg_match_all('/\d+/', $match, $matches);
33*71096e46SAndreas Gohr        $handler->addCall('multiplyentity', [$matches[0][0], $matches[0][1]], $pos);
34*71096e46SAndreas Gohr        return true;
35be906b56SAndreas Gohr    }
36be906b56SAndreas Gohr}
37