xref: /plugin/commonmark/src/Dokuwiki/Plugin/Commonmark/Extension/FootnoteToDokuwikiExtension.php (revision 73971cfef1315f0bce67e0b49beb611243fc68ed)
1f46768a8SSungbin Jeon<?php
2f46768a8SSungbin Jeon
3f46768a8SSungbin Jeon/*
4*73971cfeSSungbin Jeon * This file is part of the clockoon/dokuwiki-commonmark-plugin package.
5f46768a8SSungbin Jeon *
6*73971cfeSSungbin Jeon * (c) Sungbin Jeon <clockoon@gmail.com>
7*73971cfeSSungbin Jeon *
8*73971cfeSSungbin Jeon * Original code based on the followings:
9*73971cfeSSungbin Jeon * - CommonMark JS reference parser (https://bitly.com/commonmark-js) (c) John MacFarlane
10*73971cfeSSungbin Jeon * - league/commonmark (https://github.com/thephpleague/commonmark) (c) Colin O'Dell <colinodell@gmail.com>
11f46768a8SSungbin Jeon *
12f46768a8SSungbin Jeon * For the full copyright and license information, please view the LICENSE
13f46768a8SSungbin Jeon * file that was distributed with this source code.
14f46768a8SSungbin Jeon */
15f46768a8SSungbin Jeon
16f46768a8SSungbin Jeondeclare(strict_types=1);
17f46768a8SSungbin Jeon
18f46768a8SSungbin Jeonnamespace DokuWiki\Plugin\Commonmark\Extension;
19f46768a8SSungbin Jeon
20f46768a8SSungbin Jeonuse League\CommonMark\ConfigurableEnvironmentInterface;
21f46768a8SSungbin Jeonuse League\CommonMark\Event\DocumentParsedEvent;
22f46768a8SSungbin Jeonuse League\CommonMark\Extension\ExtensionInterface;
23f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Event\AnonymousFootnotesListener;
24f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Event\GatherFootnotesListener;
25f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Event\NumberFootnotesListener;
26f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Node\Footnote;
27f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Node\FootnoteBackref;
28f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Node\FootnoteContainer;
29f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Node\FootnoteRef;
30f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Parser\AnonymousFootnoteRefParser;
31f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Parser\FootnoteParser;
32f46768a8SSungbin Jeonuse League\CommonMark\Extension\Footnote\Parser\FootnoteRefParser;
33f46768a8SSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Extension\Renderer\Inline\FootnoteBackrefRenderer;
34f46768a8SSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Extension\Renderer\Block\FootnoteContainerRenderer;
35f46768a8SSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Extension\Renderer\Inline\FootnoteRefRenderer;
36f46768a8SSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Extension\Renderer\Block\FootnoteRenderer;
37f46768a8SSungbin Jeon
38f46768a8SSungbin Jeonfinal class FootnotetoDokuwikiExtension implements ExtensionInterface
39f46768a8SSungbin Jeon{
40f46768a8SSungbin Jeon    public function register(ConfigurableEnvironmentInterface $environment)
41f46768a8SSungbin Jeon    {
42f46768a8SSungbin Jeon        $environment->addBlockParser(new FootnoteParser(), 51);
43f46768a8SSungbin Jeon        $environment->addInlineParser(new AnonymousFootnoteRefParser(), 35);
44f46768a8SSungbin Jeon        $environment->addInlineParser(new FootnoteRefParser(), 51);
45f46768a8SSungbin Jeon
46f46768a8SSungbin Jeon        $environment->addBlockRenderer(FootnoteContainer::class, new FootnoteContainerRenderer());
47f46768a8SSungbin Jeon        $environment->addBlockRenderer(Footnote::class, new FootnoteRenderer());
48f46768a8SSungbin Jeon        $environment->addInlineRenderer(FootnoteBackref::class, new FootnoteBackrefRenderer());
49f46768a8SSungbin Jeon        $environment->addInlineRenderer(FootnoteRef::class, new FootnoteRefRenderer());
50f46768a8SSungbin Jeon
51f46768a8SSungbin Jeon        $environment->addEventListener(DocumentParsedEvent::class, [new AnonymousFootnotesListener(), 'onDocumentParsed']);
52f46768a8SSungbin Jeon        $environment->addEventListener(DocumentParsedEvent::class, [new NumberFootnotesListener(), 'onDocumentParsed']);
53f46768a8SSungbin Jeon        $environment->addEventListener(DocumentParsedEvent::class, [new GatherFootnotesListener(), 'onDocumentParsed']);
54f46768a8SSungbin Jeon    }
55f46768a8SSungbin Jeon}
56