protected function processNode($node)
    {
        if ($node instanceof DOMDocumentType) {
            return '';
        }

        if ($node instanceof DOMText) {
            // return the plain text
            return preg_replace("/\\s+/im", " ", $node->wholeText);
        }

        $tag = strtolower($node->nodeName);
        if (in_array($tag, $this->ignoredBlockTags)) {
            return '';
        }

        $lastTag = $this->lastTagName($node);
        $nextTag = $this->nextTagName($node);
        $output = '';

        if ($tag == 'ol') {
            // ordered lists start from one
            $this->liCharacter = 1;
        }
        if ($tag == 'ul') {
            // unsigned lists start with a bullet point
            $this->liCharacter = $this->bulletSymbol;
        }

        if ($tag == 'li') {
            if ($lastTag == 'li') {
                // add a new line, but not for the first item
                $output .= "\n";
            }
            // add the list character and increment if an OL
            $output .= $this->liCharacter . ' ';
            if (is_int($this->liCharacter)) {
                $this->liCharacter++;
            }

        }

        // processes child nodes:
        if ($node->childNodes) {
            $numberOfNodes = $node->childNodes->length;
            for ($i = 0; $i < $numberOfNodes; $i++) {
                $childNode = $node->childNodes->item($i);
                $output .= $this->processNode($childNode);
            }
        }

        // add new lines
        if (in_array($tag, $this->doubleNewLineTags)){
            $output = trim($output);
            $output .= "\n\n";
        }
        if (in_array($tag, $this->newLineTags)) {
            $output = trim($output);
            $output .= "\n";
        }

        return $output;

    }