xref: /webtrees/app/CommonMark/CensusTableExtension.php (revision 4a1f1d433794f86f893b59883147e57af4e94374)
10a016d04SGreg Roach<?php
20a016d04SGreg Roach/**
30a016d04SGreg Roach * webtrees: online genealogy
48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
50a016d04SGreg Roach * This program is free software: you can redistribute it and/or modify
60a016d04SGreg Roach * it under the terms of the GNU General Public License as published by
70a016d04SGreg Roach * the Free Software Foundation, either version 3 of the License, or
80a016d04SGreg Roach * (at your option) any later version.
90a016d04SGreg Roach * This program is distributed in the hope that it will be useful,
100a016d04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
110a016d04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
120a016d04SGreg Roach * GNU General Public License for more details.
130a016d04SGreg Roach * You should have received a copy of the GNU General Public License
140a016d04SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
150a016d04SGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
180a016d04SGreg Roachnamespace Fisharebest\Webtrees\CommonMark;
190a016d04SGreg Roach
20*4a1f1d43SGreg Roachuse League\CommonMark\ConfigurableEnvironmentInterface;
21*4a1f1d43SGreg Roachuse League\CommonMark\Ext\Table\Table;
22*4a1f1d43SGreg Roachuse League\CommonMark\Ext\Table\TableCell;
23*4a1f1d43SGreg Roachuse League\CommonMark\Ext\Table\TableCellRenderer;
24*4a1f1d43SGreg Roachuse League\CommonMark\Ext\Table\TableRenderer;
25*4a1f1d43SGreg Roachuse League\CommonMark\Ext\Table\TableRow;
26*4a1f1d43SGreg Roachuse League\CommonMark\Ext\Table\TableRowRenderer;
27*4a1f1d43SGreg Roachuse League\CommonMark\Ext\Table\TableSection;
28*4a1f1d43SGreg Roachuse League\CommonMark\Ext\Table\TableSectionRenderer;
29*4a1f1d43SGreg Roachuse League\CommonMark\Extension\ExtensionInterface;
300a016d04SGreg Roach
310a016d04SGreg Roach/**
320a016d04SGreg Roach * Convert webtrees 1.x census-assistant markup into tables.
330a016d04SGreg Roach * Note that webtrees 2.0 generates markdown tables directly.
340a016d04SGreg Roach *
35*4a1f1d43SGreg Roach * Based on the table parser from league/commonmark-ext-table.
360a016d04SGreg Roach */
37*4a1f1d43SGreg Roachclass CensusTableExtension implements ExtensionInterface
38c1010edaSGreg Roach{
39*4a1f1d43SGreg Roach    public function register(ConfigurableEnvironmentInterface $environment): void
40c1010edaSGreg Roach    {
41*4a1f1d43SGreg Roach        $environment
42*4a1f1d43SGreg Roach            ->addBlockParser(new CensusTableParser())
43*4a1f1d43SGreg Roach            ->addBlockRenderer(Table::class, new TableRenderer())
44*4a1f1d43SGreg Roach            ->addBlockRenderer(TableSection::class, new TableSectionRenderer())
45*4a1f1d43SGreg Roach            ->addBlockRenderer(TableRow::class, new TableRowRenderer())
46*4a1f1d43SGreg Roach            ->addBlockRenderer(TableCell::class, new TableCellRenderer());
470a016d04SGreg Roach    }
480a016d04SGreg Roach}
49