-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEMT_Tret_Etc.php
76 lines (59 loc) · 2.59 KB
/
EMT_Tret_Etc.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace corpsepk\yii2emt;
/**
* @see EMT_Tret
*/
class EMT_Tret_Etc extends \corpsepk\yii2emt\EMT_Tret
{
public $classes = array(
'nowrap' => 'word-spacing:nowrap;',
);
/**
* Базовые параметры тофа
*
* @var array
*/
public $title = "Прочее";
public $rules = array(
'acute_accent' => array(
'description' => 'Акцент',
'pattern' => '/(у|е|ы|а|о|э|я|и|ю|ё)\`(\w)/i',
'replacement' => '\1́\2'
),
'word_sup' => array(
'description' => 'Надстрочный текст после символа ^',
'pattern' => '/((\s|\ \;|^)+)\^([a-zа-яё0-9\.\:\,\-]+)(\s|\ \;|$|\.$)/ieu',
'replacement' => '"" . $this->tag($this->tag($m[3],"small"),"sup") . $m[4]'
),
'century_period' => array(
'description' => 'Тире между диапозоном веков',
'pattern' => '/(\040|\t|\ \;|^)([XIV]{1,5})(-|\&mdash\;)([XIV]{1,5})(( |\ \;)?(в\.в\.|вв\.|вв|в\.|в))/eu',
'replacement' => '$m[1] .$this->tag($m[2]."—".$m[4]." вв.","span", array("class"=>"nowrap"))'
),
'time_interval' => array(
'description' => 'Тире и отмена переноса между диапозоном времени',
'pattern' => '/([^\d\>]|^)([\d]{1,2}\:[\d]{2})(-|\&mdash\;|\&minus\;)([\d]{1,2}\:[\d]{2})([^\d\<]|$)/eui',
'replacement' => '$m[1] . $this->tag($m[2]."—".$m[4],"span", array("class"=>"nowrap")).$m[5]'
),
'expand_no_nbsp_in_nobr' => array(
'description' => 'Удаление nbsp в nobr/nowrap тэгах',
'function' => 'remove_nbsp'
),
);
protected function remove_nbsp()
{
$thetag = $this->tag("###", 'span', array('class' => "nowrap"));
$arr = explode("###", $thetag);
$b = preg_quote($arr[0], '/');
$e = preg_quote($arr[1], '/');
$match = '/(^|[^a-zа-яё])([a-zа-яё]+)\ \;('.$b.')/iu';
do {
$this->_text = preg_replace($match, '\1\3\2 ', $this->_text);
} while(preg_match($match, $this->_text));
$match = '/('.$e.')\ \;([a-zа-яё]+)($|[^a-zа-яё])/iu';
do {
$this->_text = preg_replace($match, ' \2\1\3', $this->_text);
} while(preg_match($match, $this->_text));
$this->_text = $this->preg_replace_e('/'.$b.'.*?'.$e.'/iue', 'str_replace(" "," ",$m[0]);' , $this->_text );
}
}