-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathCodeRendererTest.php
More file actions
38 lines (30 loc) · 1.11 KB
/
CodeRendererTest.php
File metadata and controls
38 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Torchlight\Commonmark\Test\V2;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\Attributes\AttributesExtension;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Parser\MarkdownParser;
use League\CommonMark\Renderer\HtmlRenderer;
use Torchlight\Commonmark\Tests\BaseRendererTest;
class CodeRendererTest extends BaseRendererTest
{
protected function version()
{
return 2;
}
protected function extension()
{
return new \Torchlight\Commonmark\V2\TorchlightExtension();
}
protected function render($markdown, $extension = null)
{
$environment = new Environment();
$environment->addExtension(new CommonMarkCoreExtension);
$environment->addExtension(new AttributesExtension);
$environment->addExtension($extension ?? $this->extension());
$parser = new MarkdownParser($environment);
$htmlRenderer = new HtmlRenderer($environment);
$document = $parser->parse($markdown);
return (string)$htmlRenderer->renderDocument($document);
}
}