1
|
|
|
<?php |
2
|
|
|
namespace EMT\Tret; |
3
|
|
|
|
4
|
|
|
class Etc extends AbstractTret |
5
|
|
|
{ |
6
|
|
|
|
7
|
|
|
public $classes = array( |
8
|
|
|
'nowrap' => 'word-spacing:nowrap;', |
9
|
|
|
); |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Базовые параметры тофа |
13
|
|
|
* |
14
|
|
|
* @var array |
15
|
|
|
*/ |
16
|
|
|
public $title = "Прочее"; |
17
|
|
|
public $rules = array( |
18
|
|
|
'acute_accent' => array( |
19
|
|
|
'description' => 'Акцент', |
20
|
|
|
'pattern' => '/(у|е|ы|а|о|э|я|и|ю|ё)\`(\w)/i', |
21
|
|
|
'replacement' => '\1́\2' |
22
|
|
|
), |
23
|
|
|
|
24
|
|
|
'word_sup' => array( |
25
|
|
|
'description' => 'Надстрочный текст после символа ^', |
26
|
|
|
'pattern' => '/((\s|\ \;|^)+)\^([a-zа-яё0-9\.\:\,\-]+)(\s|\ \;|$|\.$)/ieu', |
27
|
|
|
'replacement' => '"" . $this->tag($this->tag($m[3],"small"),"sup") . $m[4]' |
28
|
|
|
), |
29
|
|
|
'century_period' => array( |
30
|
|
|
'description' => 'Тире между диапозоном веков', |
31
|
|
|
'pattern' => '/(\040|\t|\ \;|^)([XIV]{1,5})(-|\&mdash\;)([XIV]{1,5})(( |\ \;)?(в\.в\.|вв\.|вв|в\.|в))/eu', |
32
|
|
|
'replacement' => '$m[1] .$this->tag($m[2]."—".$m[4]." вв.","span", array("class"=>"nowrap"))' |
33
|
|
|
), |
34
|
|
|
'time_interval' => array( |
35
|
|
|
'description' => 'Тире и отмена переноса между диапозоном времени', |
36
|
|
|
'pattern' => '/([^\d\>]|^)([\d]{1,2}\:[\d]{2})(-|\&mdash\;|\&minus\;)([\d]{1,2}\:[\d]{2})([^\d\<]|$)/eui', |
37
|
|
|
'replacement' => '$m[1] . $this->tag($m[2]."—".$m[4],"span", array("class"=>"nowrap")).$m[5]' |
38
|
|
|
), |
39
|
|
|
'expand_no_nbsp_in_nobr' => array( |
40
|
|
|
'description' => 'Удаление nbsp в nobr/nowrap тэгах', |
41
|
|
|
'function' => 'remove_nbsp' |
42
|
|
|
), |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
protected function remove_nbsp() |
46
|
|
|
{ |
47
|
|
|
$thetag = $this->tag("###", 'span', array('class' => "nowrap")); |
48
|
|
|
$arr = explode("###", $thetag); |
49
|
|
|
$b = preg_quote($arr[0], '/'); |
50
|
|
|
$e = preg_quote($arr[1], '/'); |
51
|
|
|
|
52
|
|
|
$match = '/(^|[^a-zа-яё])([a-zа-яё]+)\ \;(' . $b . ')/iu'; |
53
|
|
|
do { |
54
|
|
|
$this->_text = preg_replace($match, '\1\3\2 ', $this->_text); |
55
|
|
|
} while (preg_match($match, $this->_text)); |
56
|
|
|
|
57
|
|
|
$match = '/(' . $e . ')\ \;([a-zа-яё]+)($|[^a-zа-яё])/iu'; |
58
|
|
|
do { |
59
|
|
|
$this->_text = preg_replace($match, ' \2\1\3', $this->_text); |
60
|
|
|
} while (preg_match($match, $this->_text)); |
61
|
|
|
|
62
|
|
|
$this->_text = $this->preg_replace_e('/' . $b . '.*?' . $e . '/iue', 'str_replace(" "," ",$m[0]);', $this->_text); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|