xref: /webtrees/app/CommonMark/CensusTableStartParser.php (revision 1ff45046fabc22237b5d0d8e489c96f031fc598d)
16f595250SGreg Roach<?php
26f595250SGreg Roach
36f595250SGreg Roach/**
46f595250SGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
66f595250SGreg Roach * This program is free software: you can redistribute it and/or modify
76f595250SGreg Roach * it under the terms of the GNU General Public License as published by
86f595250SGreg Roach * the Free Software Foundation, either version 3 of the License, or
96f595250SGreg Roach * (at your option) any later version.
106f595250SGreg Roach * This program is distributed in the hope that it will be useful,
116f595250SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
126f595250SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
136f595250SGreg Roach * GNU General Public License for more details.
146f595250SGreg Roach * You should have received a copy of the GNU General Public License
156f595250SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
166f595250SGreg Roach */
176f595250SGreg Roach
186f595250SGreg Roachdeclare(strict_types=1);
196f595250SGreg Roach
206f595250SGreg Roachnamespace Fisharebest\Webtrees\CommonMark;
216f595250SGreg Roach
226f595250SGreg Roachuse League\CommonMark\Parser\Block\BlockStart;
236f595250SGreg Roachuse League\CommonMark\Parser\Block\BlockStartParserInterface;
246f595250SGreg Roachuse League\CommonMark\Parser\Cursor;
256f595250SGreg Roachuse League\CommonMark\Parser\MarkdownParserStateInterface;
266f595250SGreg Roach
276f595250SGreg Roach/**
286f595250SGreg Roach * Convert webtrees 1.x census-assistant markup into tables.
296f595250SGreg Roach * Note that webtrees 2.0 generates markdown tables directly.
306f595250SGreg Roach */
316f595250SGreg Roachclass CensusTableStartParser implements BlockStartParserInterface
326f595250SGreg Roach{
33*1ff45046SGreg Roach    public function tryStart(Cursor $cursor, MarkdownParserStateInterface $parserState): BlockStart|null
346f595250SGreg Roach    {
356f595250SGreg Roach        if ($cursor->getLine() === CensusTableExtension::CA_PREFIX) {
366f595250SGreg Roach            return BlockStart::of(new CensusTableContinueParser())
376f595250SGreg Roach                ->at($cursor);
386f595250SGreg Roach        }
396f595250SGreg Roach
4012e45925SGreg Roach        return BlockStart::none();
416f595250SGreg Roach    }
426f595250SGreg Roach}
43