private static function split_non_markdownable($html)
{
if (empty($html)) {
return array();
}
preg_match('#<(img|video|audio|iframe).*?(?:>(.*?)</\\1>|/?>)#si', $html, $matches);
if (!$matches) {
return array(array('name' => 'p', 'value' => $html));
}
list($whole, $tag_name) = $matches;
list($left, $right) = explode($whole, $html, 3);
$para = array('name' => 'p', 'value' => self::clean_html($left . '</p>'));
// If the paragraph is empty, just return the right-hand-side
if ('<p></p>' == $para['value']) {
return array_merge(array(array('name' => $tag_name, 'value' => $whole)), self::split_non_markdownable(self::clean_html('<p>' . $right)));
}
return array_merge(array($para, array('name' => $tag_name, 'value' => $whole)), self::split_non_markdownable(self::clean_html('<p>' . $right)));
}