Advertisement
zero50x

Закрытие тегов (Tidy)

May 23rd, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <?
  2. error_reporting(0);
  3. $html = $_POST['html'];
  4. $config = array( 'indent'         => false,
  5.             'output-xhtml'   => false,
  6.             'show-body-only'   => 1,
  7.             'wrap'           => 200);
  8. $Tidy = new tidy();
  9. $Tidy->parseString($html, $config, 'utf8');
  10. $Tidy->cleanRepair();
  11.  
  12. $html = $Tidy;
  13.  preg_match_all("#\<(.*?)\>#s", $html, $otv,PREG_OFFSET_CAPTURE);
  14.   //print_r($otv);
  15.  
  16.   for($i=0;$i<count($otv[0]);$i++){
  17.    if($otv[1][$i][0] == $otv[1][$i+1][0]) {
  18.  
  19.      $html = str_replace("<".$otv[1][$i][0]."><".$otv[1][$i][0].">", "<".$otv[1][$i][0].">", $html);
  20.  
  21.    }
  22.   }
  23.  
  24. $Tidy->parseString($html, $config, 'utf8');
  25. $Tidy->cleanRepair();
  26.  
  27. echo "<pre>" . htmlspecialchars($Tidy) . "</pre>";
  28. ?>
  29.  
  30. <!DOCTYPE html>
  31. <html lang="en">
  32.  
  33. <head></head>
  34. <body>
  35.  
  36. <div class="main">
  37.     <div class="main-inner">
  38.         <div class="container">
  39.           <div class="row">
  40.             <div class="span12">
  41.                 <div class="widget ">
  42.                     <div class="widget-header">
  43.                         <h3></h3>
  44.                     </div> <!-- /widget-header -->
  45.                     <div class="widget-content">
  46.  
  47.                    <p class="help-block">HTML текст</p>
  48.                         <form id="edit-profile"  action="1.php" method="post">
  49.             <textarea name="html"> </textarea><br><br>
  50.                         <input type="submit">
  51.                         </form>
  52.                         </div>
  53.  
  54.                     </div> <!-- /widget-content -->
  55.                 </div> <!-- /widget -->
  56.             </div> <!-- /span8 -->
  57.           </div> <!-- /row -->
  58.         </div> <!-- /container -->
  59.     </div> <!-- /main-inner -->
  60. </div> <!-- /main -->
  61.  
  62. <script src="js/jquery-1.7.2.min.js"></script>
  63. <script src="js/bootstrap.js"></script>
  64. <script src="js/base.js"></script>
  65.  
  66.   </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement