blob: 043511144b320c8ed61e2590240ed845ad476cde (
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
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
namespace dokuwiki\Parsing\ParserMode;
use dokuwiki\Parsing\Lexer\Lexer;
class Entity extends AbstractMode
{
protected $entities = [];
protected $pattern = '';
/**
* Entity constructor.
* @param string[] $entities
*/
public function __construct($entities)
{
$this->entities = $entities;
}
/** @inheritdoc */
public function preConnect()
{
if (!count($this->entities) || $this->pattern != '') return;
$sep = '';
foreach ($this->entities as $entity) {
$this->pattern .= $sep . Lexer::escape($entity);
$sep = '|';
}
}
/** @inheritdoc */
public function connectTo($mode)
{
if (!count($this->entities)) return;
if (strlen($this->pattern) > 0) {
$this->Lexer->addSpecialPattern($this->pattern, $mode, 'entity');
}
}
/** @inheritdoc */
public function getSort()
{
return 260;
}
}
|