src/View/Parsers/ShortcodeParser.php
protected function moveMarkerToCompliantHome($node, $parent, $location)
    {
        // Move before block parent
        if ($location == self::BEFORE) {
            if (isset($parent->parentNode)) {
                $parent->parentNode->insertBefore($node, $parent);
            }
        } elseif ($location == self::AFTER) {
            // Move after block parent
            $this->insertAfter($node, $parent);
        } elseif ($location == self::SPLIT) {
            // Split parent at node
            $at = $node;
            $splitee = $node->parentNode;

            while ($splitee !== $parent->parentNode) {
                /** @var DOMElement $spliter */
                $spliter = $splitee->cloneNode(false);

                $this->insertAfter($spliter, $splitee);

                while ($at->nextSibling) {
                    $spliter->appendChild($at->nextSibling);
                }

                $at = $splitee;
                $splitee = $splitee->parentNode;
            }

            $this->insertAfter($node, $parent);
        } elseif ($location == self::INLINE) {
            // Do nothing
            if (in_array(strtolower($node->tagName), self::$block_level_elements)) {
                user_error(
                    'Requested to insert block tag ' . $node->tagName . ' inline - probably this will break HTML compliance',
                    E_USER_WARNING
                );
            }
            // NOP
        } else {
            user_error('Unknown value for $location argument ' . $location, E_USER_ERROR);
        }
    }
protected function moveMarkerToCompliantHome($node, $parent, $location)
    {
        // Move before block parent
        if ($location == self::BEFORE) {
            if (isset($parent->parentNode)) {
                $parent->parentNode->insertBefore($node, $parent);
            }
        } elseif ($location == self::AFTER) {
            // Move after block parent
            $this->insertAfter($node, $parent);
        } elseif ($location == self::SPLIT) {
            // Split parent at node
            $at = $node;
            $splitee = $node->parentNode;

            while ($splitee !== $parent->parentNode) {
                /** @var DOMElement $spliter */
                $spliter = $splitee->cloneNode(false);

                $this->insertAfter($spliter, $splitee);

                while ($at->nextSibling) {
                    $spliter->appendChild($at->nextSibling);
                }

                $at = $splitee;
                $splitee = $splitee->parentNode;
            }

            $this->insertAfter($node, $parent);
        } elseif ($location == self::INLINE) {
            // Do nothing
            if (in_array(strtolower($node->tagName), self::$block_level_elements)) {
                user_error(
                    'Requested to insert block tag ' . $node->tagName . ' inline - probably this will break HTML compliance',
                    E_USER_WARNING
                );
            }
            // NOP
        } else {
            user_error('Unknown value for $location argument ' . $location, E_USER_ERROR);
        }
    }
protected function moveMarkerToCompliantHome ( $ node , $ parent , $ location ) { // Move before block parent if ( $ location == self :: BEFORE ) { if ( isset ( $ parent -> parentNode ) ) { $ parent -> parentNode -> insertBefore ( $ node , $ parent ) ; } } elseif ( $ location == self :: AFTER ) { // Move after block parent $ this -> insertAfter ( $ node , $ parent ) ; } elseif ( $ location == self :: SPLIT ) { // Split parent at node $ at = $ node ; $ splitee = $ node -> parentNode ; while ( $ splitee !== $ parent -> parentNode ) { /** @var DOMElement $spliter */ $ spliter = $ splitee -> cloneNode ( false ) ; $ this -> insertAfter ( $ spliter , $ splitee ) ; while ( $ at -> nextSibling ) { $ spliter -> appendChild ( $ at -> nextSibling ) ; } $ at = $ splitee ; $ splitee = $ splitee -> parentNode ; } $ this -> insertAfter ( $ node , $ parent ) ; } elseif ( $ location == self :: INLINE ) { // Do nothing if ( in_array ( strtolower ( $ node -> tagName ) , self :: $ block_level_elements ) ) { user_error ( 'Requested to insert block tag ' . $ node -> tagName . ' inline - probably this will break HTML compliance' , E_USER_WARNING ) ; } // NOP } else { user_error ( 'Unknown value for $location argument ' . $ location , E_USER_ERROR ) ; } }
Given a node with represents a shortcode marker and a location string, mutates the DOM to put the
marker in the compliant location

For shortcodes inserted BEFORE, that location is just before the block container that
the marker is in

For shortcodes inserted AFTER, that location is just after the block container that
the marker is in

For shortcodes inserted SPLIT, that location is where the marker is, but the DOM
is split around it up to the block container the marker is in - for instance,

<p>A<span>B<marker />C</span>D</p>

becomes

<p>A<span>B</span></p><marker /><p><span>C</span>D</p>

For shortcodes inserted INLINE, no modification is needed (but in that case the shortcode handler needs to
generate only inline blocks)

@param DOMElement $node
@param DOMElement $parent
@param int $location ShortcodeParser::BEFORE, ShortcodeParser::SPLIT or ShortcodeParser::INLINE
Given a node with represents a shortcode marker and a location string mutates the DOM to put the marker in the compliant location