diff options
-rwxr-xr-x | check-ciation-order.pl | 33 |
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; +} |