1#!/usr/bin/perl -w 2 3use English; 4 5$text = ""; 6 7while (<>) { 8 s/^[ \t]+//; 9 s/\r//; 10 $text .= $_; 11} 12$text =~ s/<section[^>]+>//gosm; 13$text =~ s/<info>.*?<\/info>//gosm; 14$text =~ s/<remark>.*?<\/remark>//gosm; 15$text =~ s/(<[Hh]\d>)\s*\n\s*/$1/gosm; 16$text =~ s/\n(<\/[Hh]\d>)/$1/gosm; 17$text =~ s/<[Hh]2>(.*?)<\/[Hh]2>/==$1==/gosm; 18$text =~ s/<[Hh]3>(.*?)<\/[Hh]3>/===$1===/gosm; 19$text =~ s/<[Hh]4>(.*?)<\/[Hh]4>/====$1====/gosm; 20$text =~ s/<formalpara><title>(.*?)<\/title>/====$1====/gosm; 21$text =~ s/<section><title>(.*?)<\/title>/===$1===/gosm; 22$text =~ s/<title>(.*?)<\/title>/==$1==/gosm; 23$text =~ s/<programlisting>/\n<programlisting>/gosm; 24$text =~ s/<\/programlisting>/\n<\/programlisting>/gosm; 25$text =~ s/<para>/\n/gosm; 26$text =~ s/<\/para>/\n/gosm; 27$text =~ s/<formalpara>/\n/gosm; 28$text =~ s/<\/formalpara>/\n/gosm; 29$text =~ s/<\/?thead>//gosm; 30$text =~ s/<\/?tbody>//gosm; 31$text =~ s/<\/[Pp]>//gosm; 32$text =~ s/(<\/?[Bb]>)/'''/gosm; 33$text =~ s/(<\/?systemitem>)/'''/gosm; 34$text =~ s/(<\/?emphasis>)/'''/gosm; 35$text =~ s/(<\/?database>)/'''/gosm; 36$text =~ s/(<\/?package[^>]*>)/''/gosm; 37$text =~ s/(<\/?replaceable[^>]*>)/''/gosm; 38$text =~ s/(<envar[^>]*>)/<tt>/gosm; 39$text =~ s/(<\/envar[^>]*>)/<\/tt>/gosm; 40$text =~ s/(<filename[^>]*>)/<tt>/gosm; 41$text =~ s/(<\/filename[^>]*>)/<\/tt>/gosm; 42$text =~ s/(<code[^>]*>)/<tt>/gosm; 43$text =~ s/(<\/code[^>]*>)/<\/tt>/gosm; 44$text =~ s/(<option[^>]*>)/<tt>/gosm; 45$text =~ s/(<\/option[^>]*>)/<\/tt>/gosm; 46$text =~ s/(<command[^>]*>)/<tt>/gosm; 47$text =~ s/(<\/command[^>]*>)/<\/tt>/gosm; 48$text =~ s/^\s*<varlistentry><term>/;/gosm; 49$text =~ s/^\s*<variablelist>/\n<variablelist>/gosm; 50$text =~ s/^\s*<\/listitem><\/varlistentry>/\n/gosm; 51$text =~ s/\s*<link [^>]+>([^<]+)<\/link>\s*/ $1 /gosm; 52$text =~ s/\s*\(<xref linkend=\"FormatsAlignmentDesc\" \/>//gosm; 53$text =~ s/ \(see <xref linkend=\"FormatsAlignmentDesc\" \/>\)//gosm; 54$text =~ s/<xref linkend=\"([^\"]+)\"[^>]*>/\[\[$1\]\]/gosm; 55$text =~ s/<application role=\"emboss[^>]+>([^<]+)<\/application[^>]*>/"\[\[Appdoc:".ucfirst($1)."|$1\]\]"/gosme; 56 57$text =~ s/(<\/?application[^>]*>)/'''/gosm; 58$text =~ s/(<\/?[Ii]>)/''/gosm; 59$text =~ s/(<\/?[Ll][Ii]>)\n/$1/gosm; 60$text =~ s/<bridgehead>([^<]+)<\/bridgehead>/===$1===/gosm; 61 62$pre = 0; 63$blank=0; 64$table = 0; 65$list = ""; 66while ($text =~ /.*?\n/gos) { 67 $t = $MATCH; 68 $t =~ s/\r//gosm; 69 70 if($t =~ s/^\s*<informaltable[^>]*>/\{| border=\"2\"/gosm) {$table=1} 71 if($t =~ s/^\s*<\/informaltable[^>]*>/|\}/gosm) {$table=0} 72 $t =~ s/^\s*<tr[^>]*>/|-/gosm; 73 $t =~ s/^\s*<td>/|/gosm; 74 $t =~ s/^\s*<th>/!/gosm; 75 $t =~ s/<\/t[dhr]>//gosm; 76 $t =~ s/<\/term><listitem>/:/gosm; 77 78 if($t =~ s/<\/[Tt][Aa][Bb][Ll][Ee][^>]*>//gosm) {$table = 0} 79 if($t =~ s/<[Tt][Aa][Bb][Ll][Ee][^>]*>//gosm) {$table = 1} 80 if($t =~ s/<\/[OoUu][Ll]>//gosm) {$list = ""} 81 if($t =~ s/<variablelist>//gosm) {$list = "d";$nlist=0} 82 if($t =~ s/<\/variablelist>//gosm) {$list = ""} 83 if($t =~ s/<[Oo][Ll]>//gosm) {$list = "o";$nlist=0} 84 if($t =~ s/<programlisting[^>]*>//gosm) {$pre = 1} 85 if($t =~ s/<\/programlisting>//gosm) {$pre = 0} 86 if($t =~ s/<\/section>[^\n]*\n//gosm) {next} 87 88 if($t =~ /<[!]--[\#]include file=\"([^\"]+)\" -->/gosm){ 89 $ifile = $1; 90 if($ifile =~ /inc\/([^.]+)[.]address/){ 91 $aname = $1; 92 if(defined($author{$aname})){$aname = $author{$aname}} 93 else {$aname = ucfirst($aname)} 94 $t = "\{\{:Appinc:Address$aname\}\}\n"; 95 } 96 elsif($ifile =~ /inc\/target([^.]*)[.]itxt/){ 97 $tgtname = ucfirst($1); 98 $t = "\{\{:Appinc:Target$tgtname\}\}\n"; 99 } 100 elsif($ifile =~ /inc\/([^.]+)[.]ihelp/){ 101 $t = ""; 102 } 103 elsif($ifile =~ /inc\/([^.]+)[.](.*)/){ 104 $name = ucfirst($1); 105 $type=ucfirst($2); 106 if(defined($names{$name})){$name = $names{$name}} 107 if(defined($types{$type})){$type = $types{$type}} 108 if($type eq "Seealso") { 109 print "==See also==\n"; 110 } 111 $t = "\{\{:Appinc:$type$name\}\}\n"; 112 } 113 } 114 115 if(!$pre & $t =~ /^\n$/) {$blank++} 116 else{$blank=0} 117 if($blank > 1){next} 118 if($blank == 1 && $table){next} 119# print "$i:"; 120 if($pre) {print " "} 121 if($t =~ s/<[Ll][Ii]>//gosm) { 122 if($nlist++){print "\n"} 123 if($list eq "u") {print "* "} 124 elsif($list eq "o") {print "# "} 125 } 126 if($nlist && $list eq "") {print "\n";$nlist=0;} 127 print "$t"; 128} 129