summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/aomart/fullref.pl
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-01-03 23:45:17 +0000
committerKarl Berry <karl@freefriends.org>2011-01-03 23:45:17 +0000
commitb90e3db7f33fec4598e155d820951f823a0721a1 (patch)
tree752938cb8f906748b1b7647d4a1d653ac86f4a44 /Master/texmf-dist/doc/latex/aomart/fullref.pl
parentd003fbe90a482efcf1e038687b21935f059cb898 (diff)
new latex package aomart 1.1 (2jan11)
git-svn-id: svn://tug.org/texlive/trunk@20919 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/aomart/fullref.pl')
-rw-r--r--Master/texmf-dist/doc/latex/aomart/fullref.pl62
1 files changed, 62 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/aomart/fullref.pl b/Master/texmf-dist/doc/latex/aomart/fullref.pl
new file mode 100644
index 00000000000..0414089ea00
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/aomart/fullref.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+#
+# Convert the refences to \fullref. Usage:
+# perl fullref.pl original.tex > converted.tex
+#
+#
+# Copyright (C) 2010 Annals of Mathematics. Public domain.
+#
+# Author: Boris Veytsman
+#
+# Version: 0.9, 2010/12/04
+
+use strict;
+
+# List of patterns for 'equation' words
+my @eqsynonyms = ('\S*equa\S*', 'relat\S*', 'item\S*',
+ 'condition\S*',
+ '\S*propert\S*');
+
+# First we skip preamble
+while(<>) {
+ print;
+ last if (/\\begin\{document\}/);
+}
+
+# This is a trick to catch \ref being the first word on the line
+my $prevline = "";
+
+# Processing document
+while (<>) {
+ if ((/^[\s~]*\(?\\ref/) || (/^[\s~]*\\eqref/)) {
+ chomp $prevline;
+ $_ = "$prevline $_";
+ } else {
+ print $prevline;
+ }
+
+ # Now the meat of the substitutions
+ # We add initial space, so all words have space before them.
+ $_ = " $_";
+ foreach my $synonym (@eqsynonyms) {
+ s/(\s)($synonym)[\s~]*\(\\ref\{([^\}]+)\}\)/$1\\pfullref{$2}{$3}/gi;
+ s/(\s)($synonym)[\s~]*\\eqref\{([^\}]+)\}/$1\\eqfullref{$2}{$3}/gi;
+ }
+ s/(\s)([^\s\\]\S*[^~\s\(\)\[\]])[\s~]*\[\\ref\{([^\}]+)\}\]/$1\\bfullref{$2}{$3}/g;
+ s/(\s)([^\s\\]\S*[^~\s\(\)\[\]])[\s~]*\\ref\{([^\}]+)\}/$1\\fullref{$2}{$3}/g;
+
+ # Now delete the extra space
+ s/^ //;
+ $prevline=$_;
+ if (/\\end\{document\}/) {
+ print;
+ last;
+ }
+}
+
+# And processing whatever is left
+while (<>) {
+ print;
+}
+
+exit 0;