1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of PHP-Typography. |
4
|
|
|
* |
5
|
|
|
* Copyright 2014-2019 Peter Putzer. |
6
|
|
|
* Copyright 2009-2011 KINGdesk, LLC. |
7
|
|
|
* |
8
|
|
|
* This program is free software; you can redistribute it and/or modify modify |
9
|
|
|
* it under the terms of the GNU General Public License as published by |
10
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
11
|
|
|
* (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU General Public License along |
19
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., |
20
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21
|
|
|
* |
22
|
|
|
* *** |
23
|
|
|
* |
24
|
|
|
* @package mundschenk-at/php-typography |
25
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
namespace PHP_Typography\Fixes\Node_Fixes; |
29
|
|
|
|
30
|
|
|
use PHP_Typography\DOM; |
31
|
|
|
use PHP_Typography\RE; |
32
|
|
|
use PHP_Typography\Settings; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Applies smart exponents (if enabled). |
36
|
|
|
* Purposefully seperated from smart_math because of HTML code injection. |
37
|
|
|
* |
38
|
|
|
* @author Peter Putzer <[email protected]> |
39
|
|
|
* |
40
|
|
|
* @since 5.0.0 |
41
|
|
|
*/ |
42
|
|
|
class Smart_Exponents_Fix extends Simple_Regex_Replacement_Fix { |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Creates a new fix object. |
46
|
|
|
* |
47
|
|
|
* @param bool $feed_compatible Optional. Default false. |
48
|
|
|
*/ |
49
|
2 |
|
public function __construct( $feed_compatible = false ) { |
50
|
2 |
|
parent::__construct( '/\b(\d+)\^(\w+)\b/u', RE::escape_tags( '$1<sup>$2</sup>' ), Settings::SMART_EXPONENTS, $feed_compatible ); |
51
|
2 |
|
} |
52
|
|
|
} |
53
|
|
|
|