Rev 11480 | Rev 14815 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
11480 | schaersvoo | 1 | #!/usr/bin/perl |
6726 | bpr | 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 ! |
||
11793 | bpr | 9 | ### introduction of \n can break the inline folds ... |
6726 | bpr | 10 | my $file=$ARGV[0]; |
11 | open (IN ,$file) ; |
||
12 | my $text = <IN>; |
||
13 | ##multiple <p> |
||
11793 | bpr | 14 | $text =~ s:(<p>\s*){2,}:<p>:g; |
6726 | bpr | 15 | ## close br and hr |
16 | $text =~ s:<(b|h)r>:<$1r/>:g; |
||
11793 | bpr | 17 | $text =~ s:<p>\s*(<li>|</?ul>|</?ol>):$1:g; |
6726 | bpr | 18 | ## delete <p> before <li><ul><ol> |
11793 | bpr | 19 | $text =~ s:<br ?/?>\s*(<li>|</?ul>|</?ol>):$1:g; |
6726 | bpr | 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 ? |
||
6858 | bpr | 25 | $text =~ s|<br ?/></table>|</table>|g; |
6726 | bpr | 26 | ## delete multiple <br> |
11793 | bpr | 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; |
||
6726 | bpr | 34 | close(IN); |
35 | |||
36 | open (OUT, ">$file"); |
||
37 | print OUT $text ; close OUT; |