Conditions | 3 |
Paths | 5 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 3.0032 |
Changes | 0 |
1 | <?php |
||
18 | 2 | protected function blockFencedCodeComplete($block) |
|
19 | { |
||
20 | 2 | if (! isset($block['element']['element']['attributes'])) { |
|
21 | return $block; |
||
22 | } |
||
23 | |||
24 | 2 | $code = $block['element']['element']['text']; |
|
25 | 2 | $languageClass = $block['element']['element']['attributes']['class']; |
|
26 | 2 | $language = explode('-', $languageClass); |
|
27 | |||
28 | try { |
||
29 | 2 | $highlighted = $this->highlighter->highlight($language[1], $code); |
|
30 | 2 | $block['element']['element']['attributes']['class'] = vsprintf('%s hljs %s', [ |
|
31 | 2 | $languageClass, |
|
32 | 2 | $highlighted->language, |
|
33 | ]); |
||
34 | 2 | $block['element']['element']['rawHtml'] = $highlighted->value; |
|
35 | 2 | unset($block['element']['element']['text']); |
|
36 | 2 | } catch (DomainException $e) { |
|
37 | // |
||
38 | } |
||
39 | |||
40 | 2 | return $block; |
|
41 | } |
||
42 | } |
||
43 |