1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
/**
|
4
|
|
|
* Evgeny Muravjev Typograph, http://mdash.ru
|
5
|
|
|
* Version: 3.4 Gold Master
|
6
|
|
|
* Release Date: September 20, 2014
|
7
|
|
|
* Authors: Evgeny Muravjev & Alexander Drutsa
|
8
|
|
|
*/
|
9
|
|
|
|
10
|
|
|
namespace Fenrizbes\TypographBundle\EMT;
|
11
|
|
|
|
12
|
|
|
/**
|
13
|
|
|
* @see EMTTret
|
14
|
|
|
*/
|
15
|
|
|
|
16
|
|
|
class EMTTretEtc extends EMTTret
|
17
|
|
|
{
|
18
|
|
|
|
19
|
|
|
|
20
|
|
|
public $classes = array(
|
21
|
|
|
'nowrap' => 'word-spacing:nowrap;',
|
22
|
|
|
);
|
23
|
|
|
|
24
|
|
|
|
25
|
|
|
/**
|
26
|
|
|
* Базовые параметры тофа
|
27
|
|
|
*
|
28
|
|
|
* @var array
|
29
|
|
|
*/
|
30
|
|
|
public $title = "Прочее";
|
31
|
|
|
public $rules = array(
|
32
|
|
|
'acute_accent' => array(
|
33
|
|
|
'description' => 'Акцент',
|
34
|
|
|
'pattern' => '/(у|е|ы|а|о|э|я|и|ю|ё)\`(\w)/i',
|
35
|
|
|
'replacement' => '\1́\2'
|
36
|
|
|
),
|
37
|
|
|
|
38
|
|
|
|
39
|
|
|
|
40
|
|
|
// 'word_sup' => array(
|
|
|
|
|
41
|
|
|
// 'description' => 'Надстрочный текст после символа ^',
|
42
|
|
|
// 'pattern' => '/((\s|\ \;|^)+)\^([a-zа-яё0-9\.\:\,\-]+)(\s|\ \;|$|\.$)/ieu',
|
43
|
|
|
// 'replacement' => '"" . $this->tag($this->tag($m[3],"small"),"sup") . $m[4]'
|
44
|
|
|
// ),
|
45
|
|
|
'century_period' => array(
|
46
|
|
|
'description' => 'Тире между диапозоном веков',
|
47
|
|
|
'pattern' => '/(\040|\t|\ \;|^)([XIV]{1,5})(-|\&mdash\;)([XIV]{1,5})(( |\ \;)?(в\.в\.|вв\.|вв|в\.|в))/eu',
|
48
|
|
|
'replacement' => '$m[1] .$this->tag($m[2]."—".$m[4]." вв.","span", array("class"=>"nowrap"))'
|
49
|
|
|
),
|
50
|
|
|
'time_interval' => array(
|
51
|
|
|
'description' => 'Тире и отмена переноса между диапозоном времени',
|
52
|
|
|
'pattern' => '/([^\d\>]|^)([\d]{1,2}\:[\d]{2})(-|\&mdash\;|\&minus\;)([\d]{1,2}\:[\d]{2})([^\d\<]|$)/eui',
|
53
|
|
|
'replacement' => '$m[1] . $this->tag($m[2]."—".$m[4],"span", array("class"=>"nowrap")).$m[5]'
|
54
|
|
|
),
|
55
|
|
|
'expand_no_nbsp_in_nobr' => array(
|
56
|
|
|
'description' => 'Удаление nbsp в nobr/nowrap тэгах',
|
57
|
|
|
'function' => 'remove_nbsp'
|
58
|
|
|
),
|
59
|
|
|
);
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
|
63
|
|
|
protected function remove_nbsp()
|
64
|
|
|
{
|
65
|
|
|
$thetag = $this->tag("###", 'span', array('class' => "nowrap"));
|
66
|
|
|
$arr = explode("###", $thetag);
|
67
|
|
|
$b = preg_quote($arr[0], '/');
|
68
|
|
|
$e = preg_quote($arr[1], '/');
|
69
|
|
|
|
70
|
|
|
$match = '/(^|[^a-zа-яё])([a-zа-яё]+)\ \;('.$b.')/iu';
|
71
|
|
|
do {
|
72
|
|
|
$this->_text = preg_replace($match, '\1\3\2 ', $this->_text);
|
73
|
|
|
} while(preg_match($match, $this->_text));
|
74
|
|
|
|
75
|
|
|
$match = '/('.$e.')\ \;([a-zа-яё]+)($|[^a-zа-яё])/iu';
|
76
|
|
|
do {
|
77
|
|
|
$this->_text = preg_replace($match, ' \2\1\3', $this->_text);
|
78
|
|
|
} while(preg_match($match, $this->_text));
|
79
|
|
|
|
80
|
|
|
$this->_text = $this->preg_replace_e('/'.$b.'.*?'.$e.'/iue', 'str_replace(" "," ",$m[0]);' , $this->_text );
|
81
|
|
|
}
|
82
|
|
|
|
83
|
|
|
}
|
84
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.