File: bibtex-validate

package info (click to toggle)
libtext-bibtex-validate-perl 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 112 kB
  • sloc: perl: 264; makefile: 2
file content (29 lines) | stat: -rwxr-xr-x 838 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl

use strict;
use warnings;
use Scalar::Util qw( blessed );
use Text::BibTeX;
use Text::BibTeX::Validate qw( validate_BibTeX );
use Text::BibTeX::Validate::Warning;

@ARGV = ( '-' ) unless @ARGV;

for my $filename (@ARGV) {
    my $bibfile = Text::BibTeX::File->new( $filename )
        || die "$filename: $!\n";
    while( my $entry = Text::BibTeX::Entry->new( $bibfile ) ) {
        my @warnings = validate_BibTeX( $entry );

        for my $warning (@warnings) {
            if( blessed $warning &&
                $warning->isa( Text::BibTeX::Validate::Warning:: ) ) {
                $warning->{file} = $filename;
                $warning->{key} = $entry->{key};
                warn "$0: $warning\n";
            } else {
                warn "$0: $filename: $entry->{key}: $warning";
            }
        }
    }
}