Fix another date bug
This commit is contained in:
parent
a2fdfbe5d3
commit
3af53ccd79
2 changed files with 19 additions and 22 deletions
|
@ -762,6 +762,7 @@ class Parser {
|
|||
while ($node = $this->nextElement($node ?? $root, $root, !$skipChildren)) {
|
||||
$skipChildren = false;
|
||||
$classes = $this->parseTokens($node, "class");
|
||||
$candidate = null;
|
||||
if (!array_intersect(["value", "value-title"], $classes) && (
|
||||
($backcompatTypes && ($this->matchRootsBackcompat($classes) || $this->matchPropertiesBackcompat($classes, $backcompatTypes, $node)))
|
||||
|| ($this->matchRootsMf2($classes) || $this->matchPropertiesMf2($classes))
|
||||
|
@ -769,8 +770,9 @@ class Parser {
|
|||
// only consider elements which are not themselves properties or roots, unless they have a value
|
||||
// NOTE: The specification doesn't mention roots, but these should surely be skipped as well
|
||||
$skipChildren = true;
|
||||
continue;
|
||||
} elseif ($node->hasAttribute("title") && in_array("value-title", $classes)) {
|
||||
$out[] = trim($node->getAttribute("title"));
|
||||
$candidate = trim($node->getAttribute("title"));
|
||||
} elseif (in_array("value", $classes)) {
|
||||
# Where an element with such a microformat property class name
|
||||
# has a descendant with class name value (a "value element")
|
||||
|
@ -806,23 +808,23 @@ class Parser {
|
|||
# for any other element, use its inner-text.
|
||||
$candidate = $this->getCleanText($node, $prefix);
|
||||
}
|
||||
if ($prefix !== "dt") {
|
||||
}
|
||||
if ($prefix !== "dt") {
|
||||
$skipChildren = true;
|
||||
$out[] = $candidate;
|
||||
} else {
|
||||
// parse and normalize date parts
|
||||
$candidate = $this->parseDatePart($candidate);
|
||||
if ($candidate && !(
|
||||
# ignore any further "value" elements that specify the date.
|
||||
(isset($out['date']) && isset($candidate['date']))
|
||||
# ignore any further "value" elements that specify the time.
|
||||
|| (isset($out['time']) && isset($candidate['time']))
|
||||
# ignore any further "value" elements that specify the timezone.
|
||||
|| (isset($out['zone']) && isset($candidate['zone']))
|
||||
)) {
|
||||
$skipChildren = true;
|
||||
$out[] = $candidate;
|
||||
} else {
|
||||
// parse and normalize date parts
|
||||
$candidate = $this->parseDatePart($candidate);
|
||||
if ($candidate && !(
|
||||
# ignore any further "value" elements that specify the date.
|
||||
(isset($out['date']) && isset($candidate['date']))
|
||||
# ignore any further "value" elements that specify the time.
|
||||
|| (isset($out['time']) && isset($candidate['time']))
|
||||
# ignore any further "value" elements that specify the timezone.
|
||||
|| (isset($out['zone']) && isset($candidate['zone']))
|
||||
)) {
|
||||
$skipChildren = true;
|
||||
$out += $candidate;
|
||||
}
|
||||
$out += $candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ class StandardTest extends \PHPUnit\Framework\TestCase {
|
|||
protected const BASE = \MensBeam\Microformats\BASE."vendor-bin/phpunit/vendor/mf2/tests/tests/";
|
||||
protected const SUPPRESSED = [
|
||||
"microformats-mixed/h-resume/mixedroots",
|
||||
"microformats-v1/hcalendar/ampm",
|
||||
"microformats-v1/hcalendar/attendees",
|
||||
"microformats-v1/hcalendar/concatenate",
|
||||
"microformats-v1/hcalendar/time",
|
||||
|
@ -38,10 +37,6 @@ class StandardTest extends \PHPUnit\Framework\TestCase {
|
|||
"microformats-v1/includes/hyperlink",
|
||||
"microformats-v1/includes/object",
|
||||
"microformats-v1/includes/table",
|
||||
"microformats-v2/h-event/concatenate",
|
||||
"microformats-v2/h-event/dt-property",
|
||||
"microformats-v2/h-review-aggregate/hevent",
|
||||
"microformats-v2/h-review-aggregate/simpleproperties",
|
||||
];
|
||||
|
||||
/** @dataProvider provideStandardTests */
|
||||
|
|
Loading…
Reference in a new issue