10a016d04SGreg Roach<?php 20a016d04SGreg Roach/** 30a016d04SGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 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 */ 160a016d04SGreg Roachnamespace Fisharebest\Webtrees\CommonMark; 170a016d04SGreg Roach 180a016d04SGreg Roachuse League\CommonMark\Block\Parser\BlockParserInterface; 190a016d04SGreg Roachuse League\CommonMark\Block\Renderer\BlockRendererInterface; 200a016d04SGreg Roachuse League\CommonMark\Extension\Extension; 210a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\Table; 220a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableCell; 230a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableCellRenderer; 240a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRenderer; 250a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRow; 260a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRowRenderer; 270a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRows; 280a016d04SGreg Roachuse Webuni\CommonMark\TableExtension\TableRowsRenderer; 290a016d04SGreg Roach 300a016d04SGreg Roach/** 310a016d04SGreg Roach * Convert webtrees 1.x census-assistant markup into tables. 320a016d04SGreg Roach * Note that webtrees 2.0 generates markdown tables directly. 330a016d04SGreg Roach * 340a016d04SGreg Roach * Based on the table parser from webuni/commonmark-table-extension. 350a016d04SGreg Roach */ 36c1010edaSGreg Roachclass CensusTableExtension extends Extension 37c1010edaSGreg Roach{ 380a016d04SGreg Roach /** 390a016d04SGreg Roach * Returns a list of block parsers to add to the existing list 400a016d04SGreg Roach * 410a016d04SGreg Roach * @return BlockParserInterface[] 420a016d04SGreg Roach */ 43*8f53f488SRico Sonntag public function getBlockParsers(): array 44c1010edaSGreg Roach { 450a016d04SGreg Roach return [ 4659f2f229SGreg Roach new CensusTableParser(), 470a016d04SGreg Roach ]; 480a016d04SGreg Roach } 490a016d04SGreg Roach 500a016d04SGreg Roach /** 510a016d04SGreg Roach * Returns a list of block renderers to add to the existing list 520a016d04SGreg Roach * 530a016d04SGreg Roach * The list keys are the block class names which the corresponding value (renderer) will handle. 540a016d04SGreg Roach * 550a016d04SGreg Roach * @return BlockRendererInterface[] 560a016d04SGreg Roach */ 57*8f53f488SRico Sonntag public function getBlockRenderers(): array 58c1010edaSGreg Roach { 590a016d04SGreg Roach return [ 6059f2f229SGreg Roach Table::class => new TableRenderer(), 6159f2f229SGreg Roach TableRows::class => new TableRowsRenderer(), 6259f2f229SGreg Roach TableRow::class => new TableRowRenderer(), 6359f2f229SGreg Roach TableCell::class => new TableCellRenderer(), 640a016d04SGreg Roach ]; 650a016d04SGreg Roach } 660a016d04SGreg Roach 670a016d04SGreg Roach /** 680a016d04SGreg Roach * @return string 690a016d04SGreg Roach */ 70*8f53f488SRico Sonntag public function getName(): string 71c1010edaSGreg Roach { 720a016d04SGreg Roach return 'censustabletable'; 730a016d04SGreg Roach } 740a016d04SGreg Roach} 75