1#!/usr/bin/perl -w 2 3%author = ("ableasby" => "Bleasby", 4 "price" => "Rice", 5 "ilongden" => "Longden", 6 "mschuster" => "Schuster", 7 ); 8 9%types = ("Ione" => "Short", 10 "Ihtml" => "", 11 "Itable" => "Options", 12 "Usage" => "Example", 13 "Input" => "Input", 14 "Output" => "Output", 15 "History" => "History", 16 "Comment" => "Comment", 17 "Isee" => "Seealso" 18 ); 19 20%names = ("Alignformats" => "AlignFormats", 21 "Assemblyformats" => "AssemblyFormats", 22 "Codonformats" => "CodonFormats", 23 "Featformats" => "FeatFormats", 24 "Ontologyformats" => "OntologyFormats", 25 "Reportformats" => "ReportFormats", 26 "Resourceformats" => "ResourceFormats", 27 "Seqformats" => "SeqFormats", 28 "Seqfeatformats" => "SeqfeatFormats", 29 "Taxonformats" => "TaxonFormats", 30 "Textformats" => "TextFormats", 31 "Urlformats" => "UrlFormats", 32 "Variationformats" => "VariationFormats", 33 "Assemblyinformats" => "AssemblyInFormats", 34 "Codoninformats" => "CodonInFormats", 35 "Featinformats" => "FeatInFormats", 36 "Ontologyinformats" => "OntologyInFormats", 37 "Resourceinformats" => "ResourceInFormats", 38 "Seqinformats" => "SeqInFormats", 39 "Seqfeatinformats" => "SeqfeatInFormats", 40 "Taxoninformats" => "TaxonInFormats", 41 "Textinformats" => "TextInFormats", 42 "Urlinformats" => "UrlInFormats", 43 "Variationformats" => "VariationFormats", 44 "Gcfiles" => "GeneticCodeFiles", 45 "Localfiles" => "LocalFiles", 46 "Graphicsdevices" => "GraphicsDevices", 47 "Drcat" => "Drcat", 48 "Edam" => "Edam", 49 "Go" => "Go", 50 "Taxon" => "Taxon", 51 "Jaspfiles" => "JasparFiles", 52 "Refiles" => "RebaseFiles", 53 "Jison-programs" => "JonIsonPrograms", 54 ); 55 56use English; 57 58$text = ""; 59while (<>) { 60 s/^[ \t]+//; 61 $text .= $_; 62} 63 64$text =~ s/^.*BEGIN MAIN CONTENT[^>]+>//gosm; 65$text =~ s/(<\/?[Hh][Tt][Mm][Ll]>)//gosm; 66$text =~ s/(<\/?[Bb][Oo][Dd][Yy][^>]*?>)//gosm; 67$text =~ s/(<[Aa]\s+name\s*=\s*\"([^\"]+)[^>]+>)[^<]*<\/[Aa]>//gosm; 68$text =~ s/<[Aa]\s+href\s*=\s*\"([^\".]+\.html)[^>]+>([^<]+)<\/[Aa]>/[http:\/\/evolution.genetics.washington.edu\/phylip\/doc\/$1 $2]/gosm; 69$text =~ s/<[Aa]\s+href\s*=\s*\"([^\"]+)[^>]+>([^<]+)<\/[Aa]>/[$1| $2]/gosm; 70$text =~ s/(<[Hh]\d>)\s*\n\s*/$1/gosm; 71$text =~ s/\n(<\/[Hh]\d>)/$1/gosm; 72$text =~ s/<\/[Dd][Ii][Vv]>//gosm; 73$text =~ s/<[Hh][Rr]>//gosm; 74$text =~ s/<[Hh]1>(.*?)<\/[Hh]1>/==$1==/gosm; 75$text =~ s/<[Hh]2>(.*?)<\/[Hh]2>/==$1==/gosm; 76$text =~ s/<[Hh]3>(.*?)<\/[Hh]3>/===$1===/gosm; 77$text =~ s/<[Hh]4>(.*?)<\/[Hh]4>/====$1====/gosm; 78 79$text =~ s/<[Pp]>/\n/gosm; 80$text =~ s/<\/?[Tt][RrDd]>//gosm; 81$text =~ s/<\/[Pp]>//gosm; 82$text =~ s/(<\/?[Bb]>)/'''/gosm; 83$text =~ s/(<\/?[Ee][Mm]>)/'''/gosm; 84$text =~ s/(<\/?[Ii]>)/''/gosm; 85$text =~ s/(<\/?[Ll][Ii]>)\n/$1/gosm; 86 87$i=0; 88$pre = 0; 89$head=0; 90$blank=0; 91$table = 0; 92$list = ""; 93while ($text =~ /.*?\n/gos) { 94 $t = $MATCH; 95 96 if($t =~ s/<[Hh][Ee][Aa][Dd]>//gosm) {$head=1} 97 if($t =~ s/<\/[Hh][Ee][Aa][Dd]>//gosm) {$head=0;next} 98 if($t =~ s/<!--#include file="header1.inc" -->//gosm) {$head=1} 99 if($t =~ s/<!--#include file="header2.inc" -->//gosm) {$head=0;next} 100 if($head) {next} 101 if($t =~ s/<\/[Tt][Aa][Bb][Ll][Ee][^>]*>//gosm) {$table = 0} 102 if($t =~ s/<[Tt][Aa][Bb][Ll][Ee][^>]*>//gosm) {$table = 1} 103 if($t =~ s/<\/[OoUu][Ll]>//gosm) {$list = ""} 104 if($t =~ s/<[Uu][Ll]>//gosm) {$list = "u";$nlist=0} 105 if($t =~ s/<[Oo][Ll]>//gosm) {$list = "o";$nlist=0} 106 if($t =~ s/<[Pp][Rr][Ee]>//gosm) {$pre = 1} 107 if($t =~ s/<\/[Pp][Rr][Ee]>//gosm) {$pre = 0} 108 109 if($t =~ /<[!]--[\#]include file=\"([^\"]+)\" -->/gosm){ 110 $ifile = $1; 111 if($ifile =~ /inc\/([^.]+)[.]address/){ 112 $aname = $1; 113 if(defined($author{$aname})){$aname = $author{$aname}} 114 else {$aname = ucfirst($aname)} 115 $t = "\{\{:Appinc:Address$aname\}\}\n"; 116 } 117 elsif($ifile =~ /inc\/target([^.]*)[.]itxt/){ 118 $tgtname = ucfirst($1); 119 $t = "\{\{:Appinc:Target$tgtname\}\}\n"; 120 } 121 elsif($ifile =~ /inc\/([^.]+)[.]ihelp/){ 122 $t = ""; 123 } 124 elsif($ifile =~ /inc\/([^.]+)[.](.*)/){ 125 $name = ucfirst($1); 126 $type=ucfirst($2); 127 if(defined($names{$name})){$name = $names{$name}} 128 if(defined($types{$type})){$type = $types{$type}} 129 if($type eq "Seealso") { 130 print "==See also==\n"; 131 } 132 $t = "\{\{:Appinc:$type$name\}\}\n"; 133 } 134 } 135 136 if(!$pre & $t =~ /^\n$/) {$blank++} 137 else{$blank=0} 138 $i++; 139 if($blank > 1){next} 140 if($blank == 1 && $list ne ""){next} 141# print "$i:"; 142 if($list ne "") {$t =~ s/\n/ /} 143 if($pre) {print " "} 144 if($t =~ s/<[Ll][Ii]>//gosm) { 145 if($nlist++){print "\n"} 146 if($list eq "u") {print "* "} 147 elsif($list eq "o") {print "# "} 148 } 149 if($nlist && $list eq "") {print "\n";$nlist=0;} 150 print "$t"; 151} 152