1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the league/commonmark package. |
7
|
|
|
* |
8
|
|
|
* (c) Colin O'Dell <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace League\CommonMark\Extension\DescriptionList; |
15
|
|
|
|
16
|
|
|
use League\CommonMark\Environment\EnvironmentBuilderInterface; |
17
|
|
|
use League\CommonMark\Event\DocumentParsedEvent; |
18
|
|
|
use League\CommonMark\Extension\DescriptionList\Event\ConsecutiveDescriptionListMerger; |
19
|
|
|
use League\CommonMark\Extension\DescriptionList\Event\LooseDescriptionHandler; |
20
|
|
|
use League\CommonMark\Extension\DescriptionList\Node\Description; |
21
|
|
|
use League\CommonMark\Extension\DescriptionList\Node\DescriptionList; |
22
|
|
|
use League\CommonMark\Extension\DescriptionList\Node\DescriptionTerm; |
23
|
|
|
use League\CommonMark\Extension\DescriptionList\Parser\DescriptionStartParser; |
24
|
|
|
use League\CommonMark\Extension\DescriptionList\Renderer\DescriptionListRenderer; |
25
|
|
|
use League\CommonMark\Extension\DescriptionList\Renderer\DescriptionRenderer; |
26
|
|
|
use League\CommonMark\Extension\DescriptionList\Renderer\DescriptionTermRenderer; |
27
|
|
|
use League\CommonMark\Extension\ExtensionInterface; |
28
|
|
|
|
29
|
|
|
final class DescriptionListExtension implements ExtensionInterface |
30
|
|
|
{ |
31
|
42 |
|
public function register(EnvironmentBuilderInterface $environment): void |
32
|
|
|
{ |
33
|
42 |
|
$environment->addBlockStartParser(new DescriptionStartParser()); |
34
|
|
|
|
35
|
42 |
|
$environment->addEventListener(DocumentParsedEvent::class, new LooseDescriptionHandler(), 1001); |
36
|
42 |
|
$environment->addEventListener(DocumentParsedEvent::class, new ConsecutiveDescriptionListMerger(), 1000); |
37
|
|
|
|
38
|
42 |
|
$environment->addRenderer(DescriptionList::class, new DescriptionListRenderer()); |
39
|
42 |
|
$environment->addRenderer(DescriptionTerm::class, new DescriptionTermRenderer()); |
40
|
42 |
|
$environment->addRenderer(Description::class, new DescriptionRenderer()); |
41
|
42 |
|
} |
42
|
|
|
} |
43
|
|
|
|