| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
# Perl script to convert LaTeX / biokey diagnistic keys from absolute to relative (automatic) |
| 4 |
# Usage: perl ./abs2rel.pl input.tex > output.tex |
| 5 |
|
| 6 |
# Anna Shipunova, 2000 |
| 7 |
# Updated by Alexey Shipunov, 20150912 |
| 8 |
# Updated by Alexey Shipunov 20150919 |
| 9 |
|
| 10 |
# NOTE: multiple keys in one document possibly lead to conflicting references |
| 11 |
# Temporary solution: modify $prefix which is specified below. |
| 12 |
|
| 13 |
$/=""; |
| 14 |
|
| 15 |
print STDERR "Converts absolute LaTeX biokey to the relative... \n"; |
| 16 |
|
| 17 |
&points(); |
| 18 |
|
| 19 |
print "\n"; |
| 20 |
while(<>){ |
| 21 |
s/\\Z(\d+)\./\\TE{$points[$1-1]}/g; |
| 22 |
s/\\T+?\s*(\d+)\./\\SS{$points[$1-1]}/sg; |
| 23 |
s/\\ZZ(\d+)\((\d+)\)\./\\SE{$points[$1-1]}{$points[$2-1]}/g; |
| 24 |
print; |
| 25 |
} |
| 26 |
|
| 27 |
# refs will be in in form $prefix[A-Z][1-3] |
| 28 |
sub points { |
| 29 |
$prefix="G"; # modify here! |
| 30 |
$B1 = $nom = ""; |
| 31 |
@points = (); |
| 32 |
for ($x = 0; $x < 26; $x++) { |
| 33 |
for ($z = 1; $z < 9; $z++) { |
| 34 |
$B1 = chr($x + 65); |
| 35 |
$nom = "$prefix$B1$z"; |
| 36 |
@points = (@points, $nom) |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
# |