summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/shipunov/scripts/abs2rel.pl
blob: abbbea419a8ba8be09769cd9693ce5e24d5a3b22 (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
#!/usr/bin/perl -w

# Perl script to convert LaTeX / biokey diagnistic keys from absolute to relative (automatic)
# Usage: perl ./abs2rel.pl input.tex > output.tex

# Anna Shipunova, 2000
# Updated by Alexey Shipunov, 20150912
# Updated by Alexey Shipunov 20150919

# NOTE: multiple keys in one document possibly lead to conflicting references
# Temporary solution: modify $prefix which is specified below.

$/="";

print STDERR "Converts absolute LaTeX biokey to the relative... \n";

&points();

print "\n";
while(<>){
 s/\\Z(\d+)\./\\TE{$points[$1-1]}/g;
 s/\\T+?\s*(\d+)\./\\SS{$points[$1-1]}/sg;
 s/\\ZZ(\d+)\((\d+)\)\./\\SE{$points[$1-1]}{$points[$2-1]}/g;
 print;
}

# refs will be in in form $prefix[A-Z][1-3]
sub points {
$prefix="G"; # modify here!
$B1 = $nom = "";
@points = ();
 for ($x = 0; $x < 26; $x++) {
  for ($z = 1; $z < 9; $z++) {
   $B1 = chr($x + 65);
   $nom = "$prefix$B1$z";
   @points = (@points, $nom)
  }
 }
}
#