Conditions | 4 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5.1576 |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
14 | 48 | public function convert(ElementInterface $element) |
|
15 | { |
||
16 | 48 | $value = $element->getValue(); |
|
17 | |||
18 | 48 | $markdown = preg_replace('~\s+~u', ' ', $value); |
|
19 | |||
20 | //escape the following characters: '*', '_' and '\' |
||
21 | 48 | $markdown = preg_replace('~([*_\\\\])~u', '\\\\$1', $markdown); |
|
22 | |||
23 | 48 | $markdown = preg_replace('~^#~u', '\\\\#', $markdown); |
|
24 | |||
25 | 48 | if ($markdown === ' ') { |
|
26 | $next = $element->getNext(); |
||
27 | if (!$next || $next->isBlock()) { |
||
28 | $markdown = ''; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | 48 | return $markdown; |
|
33 | } |
||
34 | |||
43 |