Completed
Pull Request — master (#87)
by Vladimir
02:24
created

RstSyntaxBlock   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 20 2
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Markup;
9
10
use Gregwar\RST\Directives\CodeBlock;
11
use Gregwar\RST\HTML\Nodes\CodeNode;
12
use Gregwar\RST\Parser;
13
use Highlight\Highlighter;
14
15
class RstSyntaxBlock extends CodeBlock
16
{
17 1
    public function process(Parser $parser, $node, $variable, $data, array $options)
18
    {
19
        /** @var CodeNode $node */
20
21 1
        parent::process($parser, $node, $variable, $data, $options);
22
23
        try
24
        {
25 1
            $highlighter = new Highlighter();
26 1
            $highlighted = $highlighter->highlight($node->getLanguage(), $node->getValue());
27
28 1
            $nodeOutput = sprintf('<pre><code class="hljs language-%s">%s</code></pre>', $node->getLanguage(), $highlighted->value);
29
30 1
            $node->setRaw(true);
31 1
            $node->setValue($nodeOutput);
32
        }
33 1
        catch (\Exception $e)
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
34
        {
35
        }
36 1
    }
37
}
38