protected function preventHtmlParserError($html)
    {
        // remove empty tags
        $pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/m";
        $html = preg_replace($pattern, '', $html);
        // Run twice just in case we got nested empty tags like figure / figurecaption
        $html = preg_replace($pattern, '', $html);

        return $html;
    }