Rev 17234 | 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; |
||
14815 | bpr | 7 | ### most of these "mistakes" has been done by Msg2wims |
6726 | bpr | 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]; |
14815 | bpr | 11 | my $fileout=$file; |
6726 | bpr | 12 | open (IN ,$file) ; |
13 | my $text = <IN>; |
||
14 | ##multiple <p> |
||
11793 | bpr | 15 | $text =~ s:(<p>\s*){2,}:<p>:g; |
6726 | bpr | 16 | ## close br and hr |
17170 | bpr | 17 | $text =~ s:<(b|h)r\s*>:<$1r>:g; |
14815 | bpr | 18 | ## delete multiple <br> |
17170 | bpr | 19 | $text =~ s:(<br\s*/>\s*){2,}:<br>:g; |
14815 | bpr | 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; |
||
6726 | bpr | 23 | ## delete <li> empty |
14815 | bpr | 24 | $text =~ s:(<li>\s*){1,}</(u|o)l>:</$2l>:g; |
6726 | bpr | 25 | ## transform some hr |
17170 | bpr | 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; |
||
17670 | bpr | 29 | $text =~ s:</div>\s+</div>:</div>\n</div>:g; |
30 | $text =~ s:</div>\s*(<br\s*/?>\s*){1,}</div>:</div>\n</div>:g; |
||
17234 | bpr | 31 | ## delete <br> before div |
17170 | bpr | 32 | $text =~ s:(<br\s*/?>\s*){1,}<div:<div:g; |
33 | $text =~ s:<br\s*/?> *!:<br>\n!:g; |
||
11793 | bpr | 34 | $text =~ s:\n{3,}:\n\n:g; |
6726 | bpr | 35 | close(IN); |
36 | |||
14815 | bpr | 37 | open (OUT, ">$fileout"); |
6726 | bpr | 38 | print OUT $text ; close OUT; |