Passed
Push — master ( 88ca47...f0e822 )
by Greg
05:44
created

ResponsiveTableExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 8 1
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2021 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\CommonMark;
21
22
use League\CommonMark\ConfigurableEnvironmentInterface;
23
use League\CommonMark\Extension\ExtensionInterface;
24
use League\CommonMark\Extension\Table\Table;
25
use League\CommonMark\Extension\Table\TableCell;
26
use League\CommonMark\Extension\Table\TableCellRenderer;
27
use League\CommonMark\Extension\Table\TableParser;
28
use League\CommonMark\Extension\Table\TableRow;
29
use League\CommonMark\Extension\Table\TableRowRenderer;
30
use League\CommonMark\Extension\Table\TableSection;
31
use League\CommonMark\Extension\Table\TableSectionRenderer;
32
33
/**
34
 * Class ResponsiveTableExtension - wrap markdown tables in a responsive DIV element.
35
 *
36
 * @package Fisharebest\Webtrees\CommonMark
37
 */
38
class ResponsiveTableExtension implements ExtensionInterface
39
{
40
    /**
41
     * @param ConfigurableEnvironmentInterface $environment
42
     */
43
    public function register(ConfigurableEnvironmentInterface $environment): void
44
    {
45
        $environment
46
            ->addBlockParser(new TableParser())
47
            ->addBlockRenderer(Table::class, new ResponsiveTableRenderer())
48
            ->addBlockRenderer(TableSection::class, new TableSectionRenderer())
49
            ->addBlockRenderer(TableRow::class, new TableRowRenderer())
50
            ->addBlockRenderer(TableCell::class, new TableCellRenderer());
51
    }
52
}
53