|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Groundskeeper\Tokens\Elements; |
|
4
|
|
|
|
|
5
|
|
|
use Groundskeeper\Configuration; |
|
6
|
|
|
use Groundskeeper\Tokens\ElementTypes\HeadingContent; |
|
7
|
|
|
use Groundskeeper\Tokens\ElementTypes\OpenElement; |
|
8
|
|
|
use Groundskeeper\Tokens\ElementTypes\SectioningContent; |
|
9
|
|
|
use Groundskeeper\Tokens\Token; |
|
10
|
|
|
use Psr\Log\LoggerInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* "dt" element |
|
14
|
|
|
* |
|
15
|
|
|
* https://html.spec.whatwg.org/multipage/semantics.html#the-dt-element |
|
16
|
|
|
*/ |
|
17
|
|
|
class Dt extends OpenElement |
|
18
|
|
|
{ |
|
19
|
3 |
|
protected function removeInvalidChildren(LoggerInterface $logger) |
|
20
|
|
|
{ |
|
21
|
|
|
// No "header", "footer", sectioning content, or heading content descendants. |
|
22
|
3 |
|
foreach ($this->children as $child) { |
|
23
|
3 |
|
if ($child->getType() == Token::COMMENT || |
|
24
|
3 |
|
$child->getType() == Token::TEXT) { |
|
25
|
3 |
|
continue; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
1 |
|
if ($child->getType() != Token::ELEMENT) { |
|
29
|
1 |
|
$logger->debug('Removing ' . $child . '. Element "dt" cannot contain "header", "footer", section content, or heading content elements.'); |
|
30
|
1 |
|
$this->removeChild($child); |
|
31
|
|
|
|
|
32
|
1 |
|
continue; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
1 |
|
if ($child->getName() == 'header' || |
|
36
|
1 |
|
$child->getName() == 'footer' || |
|
37
|
1 |
|
$child instanceof SectioningContent || |
|
38
|
1 |
|
$child instanceof HeadingContent) { |
|
39
|
1 |
|
$logger->debug('Removing ' . $child . '. No "header", "footer", and sectioning content, or heading content elements allowed as children of "dt" element.'); |
|
40
|
1 |
|
$this->removeChild($child); |
|
41
|
1 |
|
} |
|
42
|
3 |
|
} |
|
43
|
3 |
|
} |
|
44
|
|
|
|
|
45
|
4 |
|
protected function removeInvalidSelf(LoggerInterface $logger) |
|
46
|
|
|
{ |
|
47
|
|
|
// Must be child of "dl" element. |
|
48
|
4 |
|
$parent = $this->getParent(); |
|
49
|
4 |
|
if ($parent !== null && |
|
50
|
4 |
|
$parent->getName() != 'dl') { |
|
51
|
1 |
|
$logger->debug($this . ' must be a child of a "dl" element.'); |
|
52
|
|
|
|
|
53
|
1 |
|
return true; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
3 |
|
return false; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|