Subversion Repositories wimsdev

Rev

Rev 17234 | 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 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. my $fileout=$file;
  12. open (IN ,$file) ;
  13. my $text = <IN>;
  14. ##multiple <p>
  15. $text =~ s:(<p>\s*){2,}:<p>:g;
  16. ## close br and hr
  17. $text =~ s:<(b|h)r\s*>:<$1r>:g;
  18. ## delete multiple <br>
  19. $text =~ s:(<br\s*/>\s*){2,}:<br>:g;
  20. $text =~ s:(<p>\s*){1,}(<li>|</?ul>|</?ol>):$2:g;
  21. ## delete <br> before <li></?ul></?ol>
  22. $text =~ s:(<br\s*/?>\s*){1,}(<h[1-5].*>|<li|</h[1-5]>|</?ul>|</?ol>):$2:g;
  23. ## delete <li> empty
  24. $text =~ s:(<li>\s*){1,}</(u|o)l>:</$2l>:g;
  25. ## transform some hr
  26. $text =~ s|<hr\s+width="(\d+)%"\s*/?/?>|<hr style="width:$1%">|g;
  27. ## delete <br> before table ?
  28. $text =~ s|(<br\s*/?>\s*){1,}</table>|</table>|g;
  29. $text =~ s:</div>\s+</div>:</div>\n</div>:g;
  30. $text =~ s:</div>\s*(<br\s*/?>\s*){1,}</div>:</div>\n</div>:g;
  31. ## delete <br> before div
  32. $text =~ s:(<br\s*/?>\s*){1,}<div:<div:g;
  33. $text =~ s:<br\s*/?> *!:<br>\n!:g;
  34. $text =~ s:\n{3,}:\n\n:g;
  35. close(IN);
  36.  
  37. open (OUT, ">$fileout");
  38. print OUT $text ; close OUT;
  39.