1#!/usr/bin/perl -w 2 3use English; 4 5$text = ""; 6while (<>) { 7 s/<a href=\"\#output[.]1\">.*?<\/a>/[[#Output example|Go to the output files for this example]]/gosm; 8 s/<a href=\"\#output[.](\d+)\">.*?<\/a>/[[#Output example $1|Go to the output files for this example]]/gosm; 9 s/<a href=\"\#input[.]1\">.*?<\/a>/[[#Input example|Go to the input files for this example]]/gosm; 10 s/<a href=\"\#input[.](\d+)\">.*?<\/a>/[[#Input example $1|Go to the input files for this example]]/gosm; 11 s/<a name=[^>]*>//gosm; 12 s/<\/a>//gosm; 13 s/<\/?[Tt][DdRrHh][^>]*>//gosm; 14 s/<\/?[Tt][Aa][Bb][Ll][Ee][^>]*>//gosm; 15 s/<h3>Input files for usage example <\/h3>/===Input example===/gosm; 16 s/<h3>Input files for usage example (\d+)<\/h3>/===Input example $1===/gosm; 17 s/<h3>Output files for usage example <\/h3>/===Output example===/gosm; 18 s/<h3>Output files for usage example (\d+)<\/h3>/===Output example $1===/gosm; 19 s/<h3>(File: .*?)<\/h3>/<h4>$1<\/h4>/gosm; 20 s/<h3>(Database entry: .*?)<\/h3>/<h4>$1<\/h4>/gosm; 21 s/<[Pp]>/\n/gosm; 22 s/<\/[Pp]>//gosm; 23 s/<[Bb]><\/[Bb]>//gosm; 24 s/<[Ii]><\/[Ii]>//gosm; 25 s/(<\/?[Bb]>)/'''/gosm; 26 s/(<\/?[Ll][Ii]>)\n/$1/gosm; 27 s/<[Hh]2>(.*?)<\/[Hh]2>/==$1==/gosm; 28 s/<[Hh]3>(.*?)<\/[Hh]3>/===$1===/gosm; 29 s/<[Hh]4>(.*?)<\/[Hh]4>/====$1====/gosm; 30 $text .= $_; 31} 32 33$pre = 0; 34$blank=0; 35while ($text =~ /.*?\n/gos) { 36 $t = $MATCH; 37 38 if($t =~ s/<[Pp][Rr][Ee]>//gosm) {$pre = 1; if($t =~ /^\n$/){next}} 39 if($t =~ s/<\/[Pp][Rr][Ee]>//gosm) {$pre = 0; if($t =~ /^\n$/){next}} 40 41 if(!$pre & $t =~ /^\n$/) {$blank++} 42 else{$blank=0} 43 if($blank > 1){next} 44 if($pre) {print " "} 45 print "$t"; 46} 47