File: wikifybook.pl

package info (click to toggle)
emboss 6.6.0%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 571,584 kB
  • sloc: ansic: 460,579; java: 29,383; perl: 13,573; sh: 12,753; makefile: 3,294; csh: 706; asm: 351; xml: 239; pascal: 237; modula3: 8
file content (128 lines) | stat: -rwxr-xr-x 4,309 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/perl -w

use English;

$text = "";

while (<>) {
    s/^[ \t]+//;
    s/\r//;
    $text .= $_;
}
$text =~ s/<section[^>]+>//gosm;
$text =~ s/<info>.*?<\/info>//gosm;
$text =~ s/<remark>.*?<\/remark>//gosm;
$text =~ s/(<[Hh]\d>)\s*\n\s*/$1/gosm;
$text =~ s/\n(<\/[Hh]\d>)/$1/gosm;
$text =~ s/<[Hh]2>(.*?)<\/[Hh]2>/==$1==/gosm;
$text =~ s/<[Hh]3>(.*?)<\/[Hh]3>/===$1===/gosm;
$text =~ s/<[Hh]4>(.*?)<\/[Hh]4>/====$1====/gosm;
$text =~ s/<formalpara><title>(.*?)<\/title>/====$1====/gosm;
$text =~ s/<section><title>(.*?)<\/title>/===$1===/gosm;
$text =~ s/<title>(.*?)<\/title>/==$1==/gosm;
$text =~ s/<programlisting>/\n<programlisting>/gosm;
$text =~ s/<\/programlisting>/\n<\/programlisting>/gosm;
$text =~ s/<para>/\n/gosm;
$text =~ s/<\/para>/\n/gosm;
$text =~ s/<formalpara>/\n/gosm;
$text =~ s/<\/formalpara>/\n/gosm;
$text =~ s/<\/?thead>//gosm;
$text =~ s/<\/?tbody>//gosm;
$text =~ s/<\/[Pp]>//gosm;
$text =~ s/(<\/?[Bb]>)/'''/gosm;
$text =~ s/(<\/?systemitem>)/'''/gosm;
$text =~ s/(<\/?emphasis>)/'''/gosm;
$text =~ s/(<\/?database>)/'''/gosm;
$text =~ s/(<\/?package[^>]*>)/''/gosm;
$text =~ s/(<\/?replaceable[^>]*>)/''/gosm;
$text =~ s/(<envar[^>]*>)/<tt>/gosm;
$text =~ s/(<\/envar[^>]*>)/<\/tt>/gosm;
$text =~ s/(<filename[^>]*>)/<tt>/gosm;
$text =~ s/(<\/filename[^>]*>)/<\/tt>/gosm;
$text =~ s/(<code[^>]*>)/<tt>/gosm;
$text =~ s/(<\/code[^>]*>)/<\/tt>/gosm;
$text =~ s/(<option[^>]*>)/<tt>/gosm;
$text =~ s/(<\/option[^>]*>)/<\/tt>/gosm;
$text =~ s/(<command[^>]*>)/<tt>/gosm;
$text =~ s/(<\/command[^>]*>)/<\/tt>/gosm;
$text =~ s/^\s*<varlistentry><term>/;/gosm;
$text =~ s/^\s*<variablelist>/\n<variablelist>/gosm;
$text =~ s/^\s*<\/listitem><\/varlistentry>/\n/gosm;
$text =~ s/\s*<link [^>]+>([^<]+)<\/link>\s*/ $1 /gosm;
$text =~ s/\s*\(<xref linkend=\"FormatsAlignmentDesc\" \/>//gosm;
$text =~ s/ \(see <xref linkend=\"FormatsAlignmentDesc\" \/>\)//gosm;
$text =~ s/<xref linkend=\"([^\"]+)\"[^>]*>/\[\[$1\]\]/gosm;
$text =~ s/<application role=\"emboss[^>]+>([^<]+)<\/application[^>]*>/"\[\[Appdoc:".ucfirst($1)."|$1\]\]"/gosme;
    
$text =~ s/(<\/?application[^>]*>)/'''/gosm;
$text =~ s/(<\/?[Ii]>)/''/gosm;
$text =~ s/(<\/?[Ll][Ii]>)\n/$1/gosm;
$text =~ s/<bridgehead>([^<]+)<\/bridgehead>/===$1===/gosm;

$pre = 0;
$blank=0;
$table = 0;
$list = "";
while ($text =~ /.*?\n/gos) {
    $t = $MATCH;
    $t =~ s/\r//gosm;

    if($t =~ s/^\s*<informaltable[^>]*>/\{| border=\"2\"/gosm) {$table=1}
    if($t =~ s/^\s*<\/informaltable[^>]*>/|\}/gosm) {$table=0}
    $t =~ s/^\s*<tr[^>]*>/|-/gosm;
    $t =~ s/^\s*<td>/|/gosm;
    $t =~ s/^\s*<th>/!/gosm;
    $t =~ s/<\/t[dhr]>//gosm;
    $t =~ s/<\/term><listitem>/:/gosm;

    if($t =~ s/<\/[Tt][Aa][Bb][Ll][Ee][^>]*>//gosm) {$table = 0}
    if($t =~ s/<[Tt][Aa][Bb][Ll][Ee][^>]*>//gosm) {$table = 1}
    if($t =~ s/<\/[OoUu][Ll]>//gosm) {$list = ""}
    if($t =~ s/<variablelist>//gosm) {$list = "d";$nlist=0}
    if($t =~ s/<\/variablelist>//gosm) {$list = ""}
    if($t =~ s/<[Oo][Ll]>//gosm) {$list = "o";$nlist=0}
    if($t =~ s/<programlisting[^>]*>//gosm) {$pre = 1}
    if($t =~ s/<\/programlisting>//gosm) {$pre = 0}
    if($t =~ s/<\/section>[^\n]*\n//gosm) {next}

    if($t =~ /<[!]--[\#]include file=\"([^\"]+)\" -->/gosm){
	$ifile = $1;
	if($ifile =~ /inc\/([^.]+)[.]address/){
	    $aname = $1;
	    if(defined($author{$aname})){$aname = $author{$aname}}
	    else {$aname = ucfirst($aname)}
	    $t = "\{\{:Appinc:Address$aname\}\}\n";
	}
	elsif($ifile =~ /inc\/target([^.]*)[.]itxt/){
	    $tgtname = ucfirst($1);
	    $t = "\{\{:Appinc:Target$tgtname\}\}\n";
	}
	elsif($ifile =~ /inc\/([^.]+)[.]ihelp/){
	    $t = "";
	}
	elsif($ifile =~ /inc\/([^.]+)[.](.*)/){
	    $name = ucfirst($1);
	    $type=ucfirst($2);
	    if(defined($names{$name})){$name = $names{$name}}
	    if(defined($types{$type})){$type = $types{$type}}
	    if($type eq "Seealso") {
		print "==See also==\n";
	    }
	    $t = "\{\{:Appinc:$type$name\}\}\n";
	}
    }

    if(!$pre & $t =~ /^\n$/) {$blank++}
    else{$blank=0}
    if($blank > 1){next}
    if($blank == 1 && $table){next}
#    print "$i:";
    if($pre) {print " "}
    if($t =~ s/<[Ll][Ii]>//gosm) {
	if($nlist++){print "\n"}
	if($list eq "u") {print "* "}
	elsif($list eq "o") {print "# "}
    }
    if($nlist && $list eq "") {print "\n";$nlist=0;}
    print "$t";
}