Subversion Repositories wimsdev

Rev

Rev 11480 | Rev 14815 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/perl
  2.  
  3. use strict "subs";
  4. use locale;
  5. use warnings;
  6. $/ = undef;
  7. ### most of these "mistakes" has been done by the Msg2wims
  8. ### should be better to correct it but more difficult !
  9. ### introduction of \n can break the inline folds ...
  10. my $file=$ARGV[0];
  11. open (IN ,$file) ;
  12. my $text = <IN>;
  13. ##multiple <p>
  14. $text =~ s:(<p>\s*){2,}:<p>:g;
  15. ## close br and hr
  16. $text =~ s:<(b|h)r>:<$1r/>:g;
  17. $text =~ s:<p>\s*(<li>|</?ul>|</?ol>):$1:g;
  18. ## delete <p> before <li><ul><ol>
  19. $text =~ s:<br ?/?>\s*(<li>|</?ul>|</?ol>):$1:g;
  20. ## delete <li> empty
  21. $text =~ s:<li>\s*</(u|o)l>:</$1l>:g;
  22. ## transform some hr
  23. $text =~ s|<hr\s+width="(\d+)%"\s*/?/>|<hr style="width:$1%"/>|g;
  24. ## delete <br/> before table ?
  25. $text =~ s|<br ?/></table>|</table>|g;
  26. ## delete multiple <br>
  27. $text =~ s:(<br ?/>\s*)+:<br/>:g;
  28. $text =~ s:</div>\s+</div>:</div></div>:g;
  29. $text =~ s:</div>\s*<br/>\s*</div>:</div></div>:g;
  30. ## delete <br/> before div
  31. $text =~ s:<br/>\s*<div:<div:g;
  32. $text =~ s:<br/> *!:<br/>\n!:g;
  33. $text =~ s:\n{3,}:\n\n:g;
  34. close(IN);
  35.  
  36. open (OUT, ">$file");
  37. print OUT $text ; close OUT;
  38.