1<?php
2
3declare(strict_types=1);
4
5/*
6 * This file is part of the clockoon/dokuwiki-commonmark-plugin package.
7 *
8 * (c) Sungbin Jeon <clockoon@gmail.com>
9 *
10 * Original code based on the followings:
11 * - CommonMark JS reference parser (https://bitly.com/commonmark-js) (c) John MacFarlane
12 * - league/commonmark (https://github.com/thephpleague/commonmark) (c) Colin O'Dell <colinodell@gmail.com>
13 * - Commonmark Table extension  (c) Martin Hasoň <martin.hason@gmail.com>, Webuni s.r.o. <info@webuni.cz>, Colin O'Dell <colinodell@gmail.com>
14 *
15 * For the full copyright and license information, please view the LICENSE
16 * file that was distributed with this source code.
17 */
18
19namespace DokuWiki\Plugin\Commonmark\Extension;
20
21use League\CommonMark\Environment\EnvironmentBuilderInterface;
22use League\CommonMark\Extension\ExtensionInterface;
23use League\CommonMark\Extension\Table\TableStartParser;
24use League\CommonMark\Extension\Table\Table;
25use League\CommonMark\Extension\Table\TableCell;
26use League\CommonMark\Extension\Table\TableRow;
27use League\CommonMark\Extension\Table\TableSection;
28use Dokuwiki\Plugin\Commonmark\Extension\Renderer\Block\TableRenderer;
29use Dokuwiki\Plugin\Commonmark\Extension\Renderer\Block\TableSectionRenderer;
30use Dokuwiki\Plugin\Commonmark\Extension\Renderer\Block\TableRowRenderer;
31use Dokuwiki\Plugin\Commonmark\Extension\Renderer\Block\TableCellRenderer;
32
33final class TableExtension implements ExtensionInterface
34{
35    public function register(EnvironmentBuilderInterface $environment): void
36    {
37        $environment
38            ->addBlockStartParser(new TableStartParser())
39
40            ->addRenderer(Table::class, new TableRenderer())
41            ->addRenderer(TableSection::class, new TableSectionRenderer())
42            ->addRenderer(TableRow::class, new TableRowRenderer())
43            ->addRenderer(TableCell::class, new TableCellRenderer())
44        ;
45    }
46}
47