10a016d04SGreg Roach<?php 20a016d04SGreg Roach/** 30a016d04SGreg Roach * webtrees: online genealogy 4*8fcd0d32SGreg 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 200a016d04SGreg Roachuse League\CommonMark\Block\Parser\BlockParserInterface; 210a016d04SGreg Roachuse League\CommonMark\Block\Renderer\BlockRendererInterface; 220a016d04SGreg Roachuse League\CommonMark\Extension\Extension; 230a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\Table; 240a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableCell; 250a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableCellRenderer; 260a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRenderer; 270a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRow; 280a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRowRenderer; 290a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRows; 300a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRowsRenderer; 310a016d04SGreg Roach 320a016d04SGreg Roach/** 330a016d04SGreg Roach * Convert webtrees 1.x census-assistant markup into tables. 340a016d04SGreg Roach * Note that webtrees 2.0 generates markdown tables directly. 350a016d04SGreg Roach * 360a016d04SGreg Roach * Based on the table parser from webuni/commonmark-table-extension. 370a016d04SGreg Roach */ 38c1010edaSGreg Roachclass CensusTableExtension extends Extension 39c1010edaSGreg Roach{ 400a016d04SGreg Roach /** 410a016d04SGreg Roach * Returns a list of block parsers to add to the existing list 420a016d04SGreg Roach * 430a016d04SGreg Roach * @return BlockParserInterface[] 440a016d04SGreg Roach */ 458f53f488SRico Sonntag public function getBlockParsers(): array 46c1010edaSGreg Roach { 470a016d04SGreg Roach return [ 4859f2f229SGreg Roach new CensusTableParser(), 490a016d04SGreg Roach ]; 500a016d04SGreg Roach } 510a016d04SGreg Roach 520a016d04SGreg Roach /** 530a016d04SGreg Roach * Returns a list of block renderers to add to the existing list 540a016d04SGreg Roach * 550a016d04SGreg Roach * The list keys are the block class names which the corresponding value (renderer) will handle. 560a016d04SGreg Roach * 570a016d04SGreg Roach * @return BlockRendererInterface[] 580a016d04SGreg Roach */ 598f53f488SRico Sonntag public function getBlockRenderers(): array 60c1010edaSGreg Roach { 610a016d04SGreg Roach return [ 6259f2f229SGreg Roach Table::class => new TableRenderer(), 6359f2f229SGreg Roach TableRows::class => new TableRowsRenderer(), 6459f2f229SGreg Roach TableRow::class => new TableRowRenderer(), 6559f2f229SGreg Roach TableCell::class => new TableCellRenderer(), 660a016d04SGreg Roach ]; 670a016d04SGreg Roach } 680a016d04SGreg Roach 690a016d04SGreg Roach /** 700a016d04SGreg Roach * @return string 710a016d04SGreg Roach */ 728f53f488SRico Sonntag public function getName(): string 73c1010edaSGreg Roach { 740a016d04SGreg Roach return 'censustabletable'; 750a016d04SGreg Roach } 760a016d04SGreg Roach} 77