|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the league/commonmark package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Colin O'Dell <[email protected]> |
|
7
|
|
|
* (c) Rezo Zero / Ambroise Maupate |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
declare(strict_types=1); |
|
14
|
|
|
|
|
15
|
|
|
namespace League\CommonMark\Extension\Footnote; |
|
16
|
|
|
|
|
17
|
|
|
use League\CommonMark\ConfigurableEnvironmentInterface; |
|
18
|
|
|
use League\CommonMark\Event\DocumentParsedEvent; |
|
19
|
|
|
use League\CommonMark\Extension\ExtensionInterface; |
|
20
|
|
|
use League\CommonMark\Extension\Footnote\Event\AnonymousFootnotesListener; |
|
21
|
|
|
use League\CommonMark\Extension\Footnote\Event\GatherFootnotesListener; |
|
22
|
|
|
use League\CommonMark\Extension\Footnote\Event\NumberFootnotesListener; |
|
23
|
|
|
use League\CommonMark\Extension\Footnote\Node\Footnote; |
|
24
|
|
|
use League\CommonMark\Extension\Footnote\Node\FootnoteBackref; |
|
25
|
|
|
use League\CommonMark\Extension\Footnote\Node\FootnoteContainer; |
|
26
|
|
|
use League\CommonMark\Extension\Footnote\Node\FootnoteRef; |
|
27
|
|
|
use League\CommonMark\Extension\Footnote\Parser\AnonymousFootnoteRefParser; |
|
28
|
|
|
use League\CommonMark\Extension\Footnote\Parser\FootnoteParser; |
|
29
|
|
|
use League\CommonMark\Extension\Footnote\Parser\FootnoteRefParser; |
|
30
|
|
|
use League\CommonMark\Extension\Footnote\Renderer\FootnoteBackrefRenderer; |
|
31
|
|
|
use League\CommonMark\Extension\Footnote\Renderer\FootnoteContainerRenderer; |
|
32
|
|
|
use League\CommonMark\Extension\Footnote\Renderer\FootnoteRefRenderer; |
|
33
|
|
|
use League\CommonMark\Extension\Footnote\Renderer\FootnoteRenderer; |
|
34
|
|
|
|
|
35
|
|
|
final class FootnoteExtension implements ExtensionInterface |
|
36
|
|
|
{ |
|
37
|
42 |
|
public function register(ConfigurableEnvironmentInterface $environment) |
|
38
|
|
|
{ |
|
39
|
42 |
|
$environment->addBlockParser(new FootnoteParser(), 51); |
|
40
|
42 |
|
$environment->addInlineParser(new AnonymousFootnoteRefParser(), 35); |
|
41
|
42 |
|
$environment->addInlineParser(new FootnoteRefParser(), 51); |
|
42
|
|
|
|
|
43
|
42 |
|
$environment->addBlockRenderer(FootnoteContainer::class, new FootnoteContainerRenderer()); |
|
44
|
42 |
|
$environment->addBlockRenderer(Footnote::class, new FootnoteRenderer()); |
|
45
|
|
|
|
|
46
|
42 |
|
$environment->addInlineRenderer(FootnoteRef::class, new FootnoteRefRenderer()); |
|
47
|
42 |
|
$environment->addInlineRenderer(FootnoteBackref::class, new FootnoteBackrefRenderer()); |
|
48
|
|
|
|
|
49
|
42 |
|
$environment->addEventListener(DocumentParsedEvent::class, [new AnonymousFootnotesListener(), 'onDocumentParsed']); |
|
50
|
42 |
|
$environment->addEventListener(DocumentParsedEvent::class, [new NumberFootnotesListener(), 'onDocumentParsed']); |
|
51
|
42 |
|
$environment->addEventListener(DocumentParsedEvent::class, [new GatherFootnotesListener(), 'onDocumentParsed']); |
|
52
|
42 |
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|