| Conditions | 4 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | 57 | public function convert(ElementInterface $element) |
|
| 15 | { |
||
| 16 | 57 | $markdown = $element->getValue(); |
|
| 17 | |||
| 18 | // Remove leftover \n at the beginning of the line |
||
| 19 | 57 | $markdown = ltrim($markdown, "\n"); |
|
| 20 | |||
| 21 | // Replace sequences of invisible characters with spaces |
||
| 22 | 57 | $markdown = preg_replace('~\s+~u', ' ', $markdown); |
|
| 23 | |||
| 24 | // Escape the following characters: '*', '_' and '\' |
||
| 25 | 57 | $markdown = preg_replace('~([*_\\\\])~u', '\\\\$1', $markdown); |
|
| 26 | |||
| 27 | 57 | $markdown = preg_replace('~^#~u', '\\\\#', $markdown); |
|
| 28 | |||
| 29 | 57 | if ($markdown === ' ') { |
|
| 30 | 9 | $next = $element->getNext(); |
|
| 31 | 9 | if (!$next || $next->isBlock()) { |
|
| 32 | 3 | $markdown = ''; |
|
| 33 | 3 | } |
|
| 34 | 9 | } |
|
| 35 | |||
| 36 | 57 | return $markdown; |
|
| 37 | } |
||
| 38 | |||
| 47 |