Skip to content

Commit

Permalink
#28 auto-fix numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 16, 2023
1 parent 85be2eb commit e8e0985
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bibcop.pl
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ sub fix_author {
return join(' and ', @authors);
}

sub fix_number {
my ($value) = @_;
$value =~ s/^0+//g;
return $value;
}

# Parse the incoming .bib file and return an array
# of hash-maps, where each one is a bibentry.
sub entries {
Expand Down
4 changes: 4 additions & 0 deletions perl-tests/fixing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ package bibcop;
fixes('author', 'Knuth, Donald E.', 'Knuth, Donald E.');
fixes('author', 'Jerome, K Jerome', 'Jerome, K. Jerome');

fixes('number', '02', '2');
fixes('number', '007', '7');
fixes('number', '16', '16');

sub fixes {
my ($tag, $before, $expected) = @_;
my $fixer = "fix_$tag";
Expand Down

0 comments on commit e8e0985

Please sign in to comment.