diff --git a/lib/Microformats/Parser.php b/lib/Microformats/Parser.php index 35c282f..fb99e66 100644 --- a/lib/Microformats/Parser.php +++ b/lib/Microformats/Parser.php @@ -355,9 +355,12 @@ class Parser { * @param \DOMElement $node The element to start searching from, including itself */ protected function getRootCandidates(\DOMElement $node): void { - $query = [".", ".//*[contains(concat(' ', normalize-space(@class)), ' h-')]"]; + $query = [ + "self::*[not(ancestor::template)]", + ".//*[contains(concat(' ', normalize-space(@class)), ' h-') and not(ancestor::template)]", + ]; foreach (array_keys(static::BACKCOMPAT_ROOTS) as $root) { - $query[] = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' $root ')]"; + $query[] = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' $root ') and not(ancestor::template)]"; } $query = implode("|", $query); $this->roots = iterator_to_array($this->xpath->query($query, $node)); @@ -585,6 +588,10 @@ class Parser { if ($this->options['lang'] && ($lang = $this->getLang($root))) { $out['lang'] = $lang; } + // stop here if the root is a template, as all children of templates must be ignored + if ($root->localName === "template") { + return $out; + } // keep track of deferred properties ("use Y if X is not defined") $deferred = []; // keep track of the implied date @@ -1446,7 +1453,7 @@ class Parser { * @param bool $considerChildren Whether or not child nodes are valid next nodes */ protected function nextElement(\DOMElement $node, \DOMElement $root, bool $considerChildren): ?\DOMElement { - if ($considerChildren && $node->hasChildNodes()) { + if ($considerChildren && $node->hasChildNodes() && $node->localName !== "template") { $node = $node->firstChild; $next = $node; } elseif ($node->isSameNode($root)) { diff --git a/tests/cases/mensbeam/default-settings/implied-prop.html b/tests/cases/mensbeam/default-settings/implied-prop.html deleted file mode 100644 index 94c3c18..0000000 --- a/tests/cases/mensbeam/default-settings/implied-prop.html +++ /dev/null @@ -1,31 +0,0 @@ - -