blob: 296daaab6af2363a943f350296d78b9fc61b4a36 (
plain)
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
|
#!/usr/bin/perl -w
$/ = "";
use File::Basename;
$kl = $ARGV[0];
if ($kl && ($kl =~ /-h|-\?/)) {&message(); exit(1);}
$file = @ARGV;
if ($file < 1) {&message(); exit(1);}
$a = $ARGV[0];
open(VCHOD, "$a") || die "Sorry, I cannot open $a: $!\n";
print STDERR "Making reference tags... \n";
&hesh_stup();
while(<VCHOD>){
&format1();
&name_href();
&format2();
print;
}
sub hesh_stup {
$schet_stup = 0;
while(<VCHOD>){
if (/\\TEZA{(\w\w)}/) {$schet_stup++; $stup{"$1"} = "$schet_stup";}
if (/\\STEZA{(\w\w)}{(\w\w)}/) {$schet_stup++; $stup{"$1"} = "$schet_stup";}
}
seek (VCHOD, 0, 0);
}
END {
close (VCHOD);
}
sub format1 {
s@<!--(.*)-->@$1@g;
s@(\\TEZA{\w\w})@<span class="TEZA">$1\.</span>@gi;
s@(\\STEZA{\w\w}{\w\w})@<span class="STEZA">$1\.</span>@gi;
s@(\\SSYLKA{\w\w})@ ... <span class="SSYLKA">$1\.</span>@gi;
}
sub name_href {
s@\\TEZA{(\w\w)}@<a name=\"$1\">$stup{$1}<\/a>@g;
s@\\STEZA{(\w\w)}{(\w\w)}@<a name=\"$1\">$stup{$1}<\/a>\(<a href=\"#$2\">$stup{$2}<\/a>\)@g;
s@\\SSYLKA{(\w\w)}@<a href=\"#$1\">$stup{$1}<\/a>@g;
}
sub format2 {
s@\\documentclass.*@@gi;
s@\\usepackage.*@@gi;
s@\\begin.*@@gi;
s@\\end.*@@gi;
s@<p>%@@gi;
s@\\i *{}@i@gsi;
s@\$\\times\$@×\;@gi;
s@\\#@-@gi;
s@\\<|<<@«\;@g;
s@\\>|>>@»\;@g;
s@~@ \;@gi;
s@---|\\---@—@gi;
s@(\\T+?)(.*?)\n\n@ ...
<!--<a href="">--><span class="SP">$2</span><!--</a>-->\n\n@gsi;
s@\\KN (.+?) @<em>$1</em> @gsi;
s@\\NN (.+?) (.+?) @<em>$1 $2</em> @gsi;
s@\\K *{(.+?)}@<em>$1</em>@gsi;
s@\\J *{(.+?)}@<strong>$1</strong>@gsi;
s@\\textit *{(.+?)}@<em>$1</em>@gsi;
s@\\textbf *{(.+?)}@<strong>$1</strong>@gsi;
s@<p>\\FK@<p class="FK">@sgi;
s@<p>@<p class="ST">@sgi;
s@\\AN@–@gi;
s@\\AAN|\\AAAN@=@gi;
s@ +?@ @sgi;
s@\\'@@sgi;
s@\\i{}@@sgi;
}
sub message {
$Me = basename($0);
print <<END_OF_MESSAGE
USAGE: $Me [-h|-?] File1 [>File2]
END_OF_MESSAGE
}
#
|