summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-11-24 16:02:25 +0100
committerFlorian Pritz <bluewind@xinu.at>2018-11-24 16:02:25 +0100
commit195b6fe5f2c061eb41eb26b16e2070d9fae08bee (patch)
tree2602ab44d43e90214be68d9144a84a8263b6fcd2
parenta0b37c3f34db45cc5a67c4866eef9a5d130929e1 (diff)
downloadbin-195b6fe5f2c061eb41eb26b16e2070d9fae08bee.tar.gz
bin-195b6fe5f2c061eb41eb26b16e2070d9fae08bee.tar.xz
Add check-ciation-order.pl
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xcheck-ciation-order.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/check-ciation-order.pl b/check-ciation-order.pl
new file mode 100755
index 0000000..330c903
--- /dev/null
+++ b/check-ciation-order.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+=head1 DESCRIPTION
+
+Look for \cite commands that are not preceeded by a \citea command. This means
+that there is no text cite before a numbered cite.
+
+=cut
+
+my %seen;
+my %output;
+
+while (<<>>) {
+ while (m/\\(?<cmd>citea?)\{(?<keys>.*?)\}/g) {
+ my $keys = $+{keys};
+ my $cmd = $+{cmd};
+
+ for my $key (split /,/, $keys) {
+ $key = trim($key);
+ $seen{$key}++ if $cmd eq "citea";
+ print "incorrect order: $cmd - $key\n" if !defined $seen{$key} and $output{$key}++==0;
+ }
+ }
+}
+
+sub trim {
+ my $str = shift;
+ $str =~ s/\s*$//;
+ $str =~ s/^\s*//;
+ return $str;
+}