1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of PHP-Typography. |
4
|
|
|
* |
5
|
|
|
* Copyright 2017-2019 Peter Putzer. |
6
|
|
|
* |
7
|
|
|
* This program is free software; you can redistribute it and/or modify modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License along |
18
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., |
19
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20
|
|
|
* |
21
|
|
|
* *** |
22
|
|
|
* |
23
|
|
|
* @package mundschenk-at/php-typography |
24
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace PHP_Typography\Fixes\Node_Fixes; |
28
|
|
|
|
29
|
|
|
use PHP_Typography\DOM; |
30
|
|
|
use PHP_Typography\Settings; |
31
|
|
|
use PHP_Typography\U; |
32
|
|
|
use PHP_Typography\RE; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Prevents the number part of numbered abbreviations from being split from the basename (if enabled). |
36
|
|
|
* |
37
|
|
|
* E.G. "ISO 9000" gets replaced with "ISO 9000". |
38
|
|
|
* |
39
|
|
|
* @author Peter Putzer <[email protected]> |
40
|
|
|
* |
41
|
|
|
* @since 5.0.0 |
42
|
|
|
*/ |
43
|
|
|
class Numbered_Abbreviation_Spacing_Fix extends Simple_Regex_Replacement_Fix { |
44
|
|
|
const _ISO = 'ISO(?:\/(?:IEC|TR|TS))?'; |
45
|
|
|
const _ABBREVIATIONS = ' |
46
|
|
|
### Internationl standards |
47
|
|
|
' . self::_ISO . '| |
48
|
|
|
|
49
|
|
|
### German standards |
50
|
|
|
DIN| |
51
|
|
|
DIN[ ]EN(?:[ ]' . self::_ISO . ')?| |
52
|
|
|
DIN[ ]EN[ ]ISP |
53
|
|
|
DIN[ ]' . self::_ISO . '| |
54
|
|
|
DIN[ ]IEC| |
55
|
|
|
DIN[ ]CEN\/TS| |
56
|
|
|
DIN[ ]CLC\/TS| |
57
|
|
|
DIN[ ]CWA| |
58
|
|
|
DIN[ ]VDE| |
59
|
|
|
|
60
|
|
|
LN|VG|VDE|VDI |
61
|
|
|
|
62
|
|
|
### Austrian standards |
63
|
|
|
ÖNORM| |
64
|
|
|
ÖNORM[ ](?:A|B|C|E|F|G|H|K|L|M|N|O|S|V|Z)| |
65
|
|
|
ÖNORM[ ]EN(?:[ ]' . self::_ISO . ')?| |
66
|
|
|
ÖNORM[ ]ETS| |
67
|
|
|
|
68
|
|
|
ÖVE|ONR| |
69
|
|
|
|
70
|
|
|
### Food additives |
71
|
|
|
E |
72
|
|
|
'; // required modifiers: x (multiline pattern). |
73
|
|
|
|
74
|
|
|
const REPLACEMENT = '$1' . U::NO_BREAK_SPACE . '$2'; |
75
|
|
|
const REGEX = '/\b(' . self::_ABBREVIATIONS . ')[' . RE::NORMAL_SPACES . ']+([0-9]+)/xu'; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Creates a new fix object. |
79
|
|
|
* |
80
|
|
|
* @param bool $feed_compatible Optional. Default false. |
81
|
|
|
*/ |
82
|
26 |
|
public function __construct( $feed_compatible = false ) { |
83
|
26 |
|
parent::__construct( self::REGEX, self::REPLACEMENT, Settings::NUMBERED_ABBREVIATION_SPACING, $feed_compatible ); |
84
|
26 |
|
} |
85
|
|
|
} |
86
|
|
|
|