protected function remove(\DOMNodeList $elements)
    {
        $encoded = array('textarea', 'code');

        foreach ($elements as $element)
        {
            if ($this->childbearing($element))
            {
                continue;
            }

            $output = (string) $element->nodeValue;

            if (in_array($element->nodeName, $encoded))
            {
                $output = htmlentities($element->nodeValue);
            }

            array_push($this->data, (string) $output);

            $current = count($this->data) - 1;

            $element->nodeValue = '$' . $current . '$';
        }
    }