test

function daimasj($html){

$html=preg_replace_callback("/(?:\s*<p>\s*)?\s*(?:\<([^\s<>]*)[^<>]*\>|\&nbsp\;)(\={3,}[^\r\n\=]+\={3,})<\/\\1>(?:\s*<\/p>)?/isx",function($em){
$em[2]=strip_tags($em[2]);
return "\r\n<p>{$em[2]}</p>";
},$html);

$html=preg_replace_callback("/(<div\sclass=\"codeText\">(?:(?<!codeText).)*)(?:<\/ol[^<>]*>\s*<\/div>\s*<\/div>|<\/ol[^<>]*>\s*<\/div>|<\/ol[^<>]*>\s*|(?=<p>\=\=\=))/Uisx",function($em){
return "{$em[1]}</ol></div></div>";
},$html);

$html=preg_replace_callback("/\s*?<li(?:\s+class=\"alt\")?>(\&nbsp\;|\s|<\/?span>)*<\/li>\s*?/Uisx",function($em){
return "";
},$html);

$html=preg_replace_callback("/(<code[^<>]*>)(.*)(<\/code>)/Uisx",function($em){
$em[2]=preg_replace("/<br>/i","",$em[2]);
return $em[1].$em[2].$em[3];
},$html);

$html=preg_replace_callback("/(<div\s*class=\"codeText\">).*<ol[^<>]*>(.*)(<\/ol>\s*<\/div>\s*<\/div>)/Uisx",function($em){
$em[2]=preg_replace("/<li[^<>]*>(.*)<\/li>/Uimx","\r\n\\1",$em[2]);
return "[code=\"\"]{$em[2]}[/code]";
},$html);
$html=preg_replace_callback("/\[code\=\"?([a-zA-Z\.]*)\"?\](.*)\[\/code\]/Uisx",function($em){
$em[2]=preg_replace("/^(\s*|\r\s*\n|\n\s*\r)$/m","",$em[2]);
$em[2]=preg_replace("/(\r|\n){3,}/is","\r\n",$em[2]);
$em[2]=preg_replace("/<p><\/p>/Uisx","",$em[2]);
$tmplate="<pre class=\" language-{$em[1]}\" data-language=\"{$em[1]}\">
<code class=\" language-{$em[1]}\">
{$em[2]}
</code></pre>";
return $tmplate;
},$html);
$html=preg_replace_callback("/\s*?<li(?:\s+class=\"alt\")?>(\&nbsp\;|\s|<\/?span>)*<\/li>\s*?/Uisx",function($em){
return "";
},$html);
$html=preg_replace_callback("/<(span|h[0-9]+)\s([^<>]*)>/Uisx",function($em){
return "<$em[1]>";
},$html);


return $html;
}

  

posted @ 2019-10-02 20:11  微波炉  阅读(124)  评论(0编辑  收藏  举报