From 195b6fe5f2c061eb41eb26b16e2070d9fae08bee Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 24 Nov 2018 16:02:25 +0100 Subject: Add check-ciation-order.pl Signed-off-by: Florian Pritz --- check-ciation-order.pl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 check-ciation-order.pl 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/\\(?citea?)\{(?.*?)\}/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; +} -- cgit v1.2.3-24-g4f1b