htmltoolkit

Temp1iteratortemp2 iteratorerphtml1

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: $thereispre = preg_match_all($regexp,$html,$temp); // Preserve '\n's in content between the tags <textarea> and </textarea> $regexp2 = '#<textarea(.*?)>(.+?)</textarea>#si'; $thereistextarea = preg_match_all($regexp2,$html,$temp2); $html = str_replace("\n",' ',$html); //replace linefeed by spaces $html = str_replace("\t",' ',$html); //replace tabs by spaces $regexp3 = '#\s{2,}#s'; // turn 2+ consecutive spaces into one $html = preg_replace($regexp3,' ',$html); $iterator = 0; while($thereispre) //Recover <pre attributes>content</pre> { $temp[2][$iterator] = str_replace("\n","<br>",$temp[2][$iterator]); $html = preg_replace($regexp,'<erp'.$temp[1][$iterator].'>'.$temp[2] [$iterator].'</erp>',$html,1); $thereispre; $iterator++; } $iterator = 0; while($thereistextarea) //Recover <textarea attributes>content</textarea> { $temp2[2][$iterator] = str_replace(" "," ",$temp2[2][$iterator]); $html = preg_replace($regexp2,'<aeratxet'.$temp2[1][$iterator].'>'.trim($temp2[2] [$iterator]).'</aeratxet>',$html,1); $thereistextarea; $iterator++; } //Restore original tag names $html = str_replace("<erp","<pre",$html); $html = str_replace("</erp>","</pre>",$html); $html = str_replace("<aeratxet","<textarea",$html); $html = str_replace("</aeratxet>","</textarea>",$html); // (the code above might slowdown overall performance?) } //end of if($usepre) else { $html = str_replace("\n",' ',$html); //replace linefeed by spaces $html = str_replace("\t",' ',$html); //replace tabs by spaces $regexp = '/\\s{2,}/s'; // turn 2+ consecutive spaces into one $html = preg_replace($regexp,' ',$html); } // remove redundant <br>'s before </div>, avoiding huge leaps between text blocks // such things appear on computergenerated HTML...
View Full Document

This note was uploaded on 08/14/2009 for the course ITP 204X taught by Professor Dent during the Spring '08 term at USC.

Ask a homework question - tutors are online