更新了一个函数,使得转换后的代码更好看
//根据您的需求,对word转到的html格式化 function formathtml($content){ $temps=explode('<html>',$content); $content=$temps[1]; $content=str_replace('</html>','',$content); $content=preg_replace("/<(title.*?)>(.*?)<(\/title.*?)>/si","",$content); //过滤title标签 $content=preg_replace("/<(\/?body.*?)>/si","",$content); $content=preg_replace("/<(\/?head.*?)>/si","",$content); $content=preg_replace("/<(\/?meta.*?)>/si","",$content); // $content=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si","",$content); //过滤style标签 // here is your code // line-height: 100% $content=str_replace('line-height: 100%','line-height: 26px',$content); // position: absolute; 替换为 position: relative; $content=str_replace('position: absolute;','position: relative;',$content); /* $content = preg_replace_callback( '| ([0-9]{1,2})pt|', function ($matches) { return ' '.(2*$matches[1]).'px'; }, $content ); */ return $content; }
|