public function __construct(
protected HtmlDocument $doc,
protected Closure $pageContentForId,
public function __construct(
protected HtmlDocument $doc,
protected Closure $pageContentForId,
- $htmlContent = $this->pageContentForId->call($this, $tag->getPageId());
- $content = new PageIncludeContent($htmlContent, $tag);
+ /** @var PageIncludeContent $content */
+ $content = $this->pageContentForId->call($this, $tag);
foreach ($node->childNodes as $childNode) {
if ($childNode->nodeName === '#text') {
array_push($includeTags, ...$this->splitTextNodesAtTags($childNode));
foreach ($node->childNodes as $childNode) {
if ($childNode->nodeName === '#text') {
array_push($includeTags, ...$this->splitTextNodesAtTags($childNode));
$parentText = $parent->textContent;
$tagPos = strpos($parentText, $tag->tagContent);
$before = $tagPos < (strlen($parentText) / 2);
$parentText = $parent->textContent;
$tagPos = strpos($parentText, $tag->tagContent);
$before = $tagPos < (strlen($parentText) / 2);
$parentNode->parentNode->insertBefore($parentClone, $parentNode);
$parentClone->removeAttribute('id');
$parentNode->parentNode->insertBefore($parentClone, $parentNode);
$parentClone->removeAttribute('id');
- if ($element->parentNode && !$element->hasChildNodes()) {
- $element->parentNode->removeChild($element);
+ while ($element->parentNode && !$element->hasChildNodes()) {
+ $parent = $element->parentNode;
+ $parent->removeChild($element);
+ $element = $parent;