-
Notifications
You must be signed in to change notification settings - Fork 1
/
EMT_Tret_OptAlign.php
78 lines (69 loc) · 2.85 KB
/
EMT_Tret_OptAlign.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
77
78
<?php
namespace corpsepk\yii2emt;
/**
* @see EMT_Tret
*/
class EMT_Tret_OptAlign extends \corpsepk\yii2emt\EMT_Tret
{
public $classes = array(
'oa_obracket_sp_s' => "margin-right:0.3em;",
"oa_obracket_sp_b" => "margin-left:-0.3em;",
"oa_obracket_nl_b" => "margin-left:-0.3em;",
"oa_comma_b" => "margin-right:-0.2em;",
"oa_comma_e" => "margin-left:0.2em;",
'oa_oquote_nl' => "margin-left:-0.44em;",
'oa_oqoute_sp_s' => "margin-right:0.44em;",
'oa_oqoute_sp_q' => "margin-left:-0.44em;",
);
/**
* Базовые параметры тофа
*
* @var array
*/
public $title = "Оптическое выравнивание";
public $rules = array(
'oa_oquote' => array(
'description' => 'Оптическое выравнивание открывающей кавычки',
//'disabled' => true,
'pattern' => array(
'/([a-zа-яё\-]{3,})(\040|\ \;|\t)(\«\;)/uie',
'/(\n|\r|^)(\«\;)/ei'
),
'replacement' => array(
'$m[1] . $this->tag($m[2], "span", array("class"=>"oa_oqoute_sp_s")) . $this->tag($m[3], "span", array("class"=>"oa_oqoute_sp_q"))',
'$m[1] . $this->tag($m[2], "span", array("class"=>"oa_oquote_nl"))',
),
),
'oa_oquote_extra' => array(
'description' => 'Оптическое выравнивание кавычки',
//'disabled' => true,
'function' => 'oaquote_extra'
),
'oa_obracket_coma' => array(
'description' => 'Оптическое выравнивание для пунктуации (скобка и запятая)',
//'disabled' => true,
'pattern' => array(
'/(\040|\ \;|\t)\(/ei',
'/(\n|\r|^)\(/ei',
'/([а-яёa-z0-9]+)\,(\040+)/iue',
),
'replacement' => array(
'$this->tag($m[1], "span", array("class"=>"oa_obracket_sp_s")) . $this->tag("(", "span", array("class"=>"oa_obracket_sp_b"))',
'$m[1] . $this->tag("(", "span", array("class"=>"oa_obracket_nl_b"))',
'$m[1] . $this->tag(",", "span", array("class"=>"oa_comma_b")) . $this->tag(" ", "span", array("class"=>"oa_comma_e"))',
),
),
);
/**
* Если стоит открывающая кавычка после <p> надо делать её висячей
*
* @return void
*/
protected function oaquote_extra()
{
$this->_text = $this->preg_replace_e(
'/(<' .self::BASE64_PARAGRAPH_TAG . '>)([\040\t]+)?(\«\;)/e',
'$m[1] . $this->tag($m[3], "span", array("class"=>"oa_oquote_nl"))',
$this->_text);
}
}