xref: /webtrees/app/CommonMark/CensusTableExtension.php (revision d11be7027e34e3121be11cc025421873364403f9)
10a016d04SGreg Roach<?php
23976b470SGreg Roach
30a016d04SGreg Roach/**
40a016d04SGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
60a016d04SGreg Roach * This program is free software: you can redistribute it and/or modify
70a016d04SGreg Roach * it under the terms of the GNU General Public License as published by
80a016d04SGreg Roach * the Free Software Foundation, either version 3 of the License, or
90a016d04SGreg Roach * (at your option) any later version.
100a016d04SGreg Roach * This program is distributed in the hope that it will be useful,
110a016d04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
120a016d04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
130a016d04SGreg Roach * GNU General Public License for more details.
140a016d04SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
160a016d04SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
200a016d04SGreg Roachnamespace Fisharebest\Webtrees\CommonMark;
210a016d04SGreg Roach
226f595250SGreg Roachuse League\CommonMark\Environment\EnvironmentBuilderInterface;
236f595250SGreg Roachuse League\CommonMark\Extension\ConfigurableExtensionInterface;
246f595250SGreg Roachuse League\Config\ConfigurationBuilderInterface;
250a016d04SGreg Roach
260a016d04SGreg Roach/**
270a016d04SGreg Roach * Convert webtrees 1.x census-assistant markup into tables.
280a016d04SGreg Roach * Note that webtrees 2.0 generates markdown tables directly.
290a016d04SGreg Roach *
306f595250SGreg Roach * .start_formatted_area.
316f595250SGreg Roach * .b.HEADING1|.b.HEADING2|.b.HEADING3
326f595250SGreg Roach * COL1|COL2|COL3
336f595250SGreg Roach * COL1|COL2|COL3
346f595250SGreg Roach * .end_formatted_area.
350a016d04SGreg Roach */
366f595250SGreg Roachclass CensusTableExtension implements ConfigurableExtensionInterface
37c1010edaSGreg Roach{
386f595250SGreg Roach    // Keywords used to create the webtrees 1.x census-assistant notes.
396f595250SGreg Roach    public const CA_PREFIX = '.start_formatted_area.';
406f595250SGreg Roach    public const CA_SUFFIX = '.end_formatted_area.';
416f595250SGreg Roach    public const TH_PREFIX = '.b.';
426f595250SGreg Roach
436f595250SGreg Roach    /**
446f595250SGreg Roach     * The core TableExtension will already have configured tables.
456f595250SGreg Roach     *
466f595250SGreg Roach     * @param ConfigurationBuilderInterface $builder
476f595250SGreg Roach     */
486f595250SGreg Roach    public function configureSchema(ConfigurationBuilderInterface $builder): void
49c1010edaSGreg Roach    {
506f595250SGreg Roach    }
516f595250SGreg Roach
526f595250SGreg Roach    /**
536f595250SGreg Roach     * Assumes we have also registered the core TableExtension.
546f595250SGreg Roach     *
556f595250SGreg Roach     * @param EnvironmentBuilderInterface $environment
566f595250SGreg Roach     */
576f595250SGreg Roach    public function register(EnvironmentBuilderInterface $environment): void
586f595250SGreg Roach    {
596f595250SGreg Roach        $environment->addBlockStartParser(new CensusTableStartParser());
600a016d04SGreg Roach    }
610a016d04SGreg Roach}
62