// skip attributes in end tag
if (($pos = strpos($tag, ' '))!==false)
$tag = substr($tag, 0, $pos);
$parent_lower = strtolower($this->parent->tag);
$tag_lower = strtolower($tag);
if ($parent_lower!==$tag_lower) {
if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower])) {
$this->parent->_[HDOM_INFO_END] = 0;
$org_parent = $this->parent;
while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
$this->parent = $this->parent->parent;
if (strtolower($this->parent->tag)!==$tag_lower) {
$this->parent = $org_parent; // restore origonal parent
if ($this->parent->parent) $this->parent = $this->parent->parent;
$this->parent->_[HDOM_INFO_END] = $this->cursor;
return $this->as_text_node($tag);
}
}
else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) {
$this->parent->_[HDOM_INFO_END] = 0;
$org_parent = $this->parent;
while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
$this->parent = $this->parent->parent;
if (strtolower($this->parent->tag)!==$tag_lower) {
$this->parent = $org_parent; // restore origonal parent
$this->parent->_[HDOM_INFO_END] = $this->cursor;
return $this->as_text_node($tag);
}
}
else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) {
$this->parent->_[HDOM_INFO_END] = 0;
$this->parent = $this->parent->parent;
}
else
return $this->as_text_node($tag);
}
$this->parent->_[HDOM_INFO_END] = $this->cursor;
if ($this->parent->parent) $this->parent = $this->parent->parent;