/** * Cleanup for clipped HTML prior to parsing with RecipeParser. * * @param string HTML * @return string HTML */ public static function cleanupClippedRecipeHtml($html) { $html = preg_replace('/(\\r\\n|\\r)/', "\n", $html); // Normalize line breaks $html = str_replace(' ', ' ', $html); // get rid of non-breaking space (html code) $html = str_replace(' ', ' ', $html); // get rid of non-breaking space (numeric) $html = preg_replace('/\\xC2\\xA0/', ' ', $html); // get rid of non-breaking space (UTF-8) $html = preg_replace('/[\\x{0096}-\\x{0097}]/u', '-', $html); // ndash, mdash (bonappetit) // Strip out script tags so they don't accidentally get executed if we ever display // clipped content to end-users. $html = RecipeParser_Text::stripTagAndContents('script', $html); return $html; }