Rev 11479 | Rev 11793 | 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 ! |
||
9 | my $file=$ARGV[0]; |
||
10 | open (IN ,$file) ; |
||
11 | my $text = <IN>; |
||
12 | ##multiple <p> |
||
13 | $text =~ s:(<p>\s*){2,}:<p>\n:g; |
||
14 | ## close br and hr |
||
15 | $text =~ s:<(b|h)r>:<$1r/>:g; |
||
16 | $text =~ s:<p>\s*(<li>|</?ul>|</?ol>):\n$1\n:g; |
||
17 | ## delete <p> before <li><ul><ol> |
||
6858 | bpr | 18 | $text =~ s:<br ?/?>\s*(<li>|</?ul>|</?ol>):\n$1\n:g; |
6726 | bpr | 19 | ## delete <li> empty |
20 | $text =~ s:<li>\s*</(u|o)l>:</$1l>:g; |
||
21 | ## transform some hr |
||
22 | $text =~ s|<hr\s+width="(\d+)%"\s*/?/>|<hr style="width:$1%"/>|g; |
||
23 | ## delete <br/> before table ? |
||
6858 | bpr | 24 | $text =~ s|<br ?/></table>|</table>|g; |
6726 | bpr | 25 | ## delete multiple <br> |
8545 | bpr | 26 | $text =~ s:(<br ?/>\s*)+:<br/>\n:g; |
6726 | bpr | 27 | $text =~ s:</div>\s+</div>:</div>\n</div>:g; |
28 | $text =~ s:</div>\s*<br/>\s*</div>:</div>\n</div>:g; |
||
29 | close(IN); |
||
30 | |||
31 | open (OUT, ">$file"); |
||
32 | print OUT $text ; close OUT; |