1f46768a8SSungbin Jeon<?php 2f46768a8SSungbin Jeon 3f46768a8SSungbin Jeon/* 473971cfeSSungbin Jeon * This file is part of the clockoon/dokuwiki-commonmark-plugin package. 5f46768a8SSungbin Jeon * 673971cfeSSungbin Jeon * (c) Sungbin Jeon <clockoon@gmail.com> 773971cfeSSungbin Jeon * 873971cfeSSungbin Jeon * Original code based on the followings: 973971cfeSSungbin Jeon * - CommonMark JS reference parser (https://bitly.com/commonmark-js) (c) John MacFarlane 1073971cfeSSungbin 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 20*94a075eeSSungbin Jeonuse League\CommonMark\Environment\EnvironmentBuilderInterface; 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{ 40*94a075eeSSungbin Jeon public function register(EnvironmentBuilderInterface $environment): void 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