Conditions | 4 |
Paths | 6 |
Total Lines | 26 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
14 | 24 | public function convert(ElementInterface $element) |
|
15 | { |
||
16 | 24 | $value = $element->getValue(); |
|
17 | |||
18 | 24 | $markdown = ''; |
|
19 | |||
20 | /* |
||
21 | * > ocurrences must be escaped, otherwise instead of rendering p tags as paragraph blocks, |
||
22 | * the > will make them appear as a blockquote. |
||
23 | * To achieve this, the content of the paragraph must be exploded and then each line must be check |
||
24 | 78 | * if the first character (sans blank space) is a > |
|
25 | */ |
||
26 | 78 | ||
27 | $lines = explode("\n", $value); |
||
28 | foreach ($lines as $line) { |
||
29 | if (strpos(ltrim($line), '>') === 0) { |
||
30 | // Found a > char, escaping it |
||
31 | $markdown .= '\\' . ltrim($line); |
||
32 | } else { |
||
33 | $markdown .= $line; |
||
34 | } |
||
35 | $markdown .= "\n"; |
||
36 | } |
||
37 | |||
38 | return trim($markdown) !== '' ? rtrim($markdown) . "\n\n" : ''; |
||
39 | } |
||
40 | |||
49 |