Skip to content

Commit

Permalink
#28 fix pages
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 16, 2023
1 parent ce80f47 commit cb0cf1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bibcop.pl
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,17 @@ sub fix_title {
return $value;
}

sub fix_pages {
my ($value) = @_;
if ($value =~ /^[1-9][0-9]*$/) {
return $value;
}
my ($left, $right) = split(/---|-|—|\s/, $value);
$left =~ s/^0+//g;
$right =~ s/^0+//g;
return $left . '--' . $right;
}

sub fix_booktitle {
my ($value) = @_;
$value = fix_capitalization($value);
Expand Down
6 changes: 6 additions & 0 deletions perl-tests/fixing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ package bibcop;
fixes('booktitle', 'Proceedings of IEEE Symposium on Art', 'Proceedings of IEEE Symposium on Art');
fixes('booktitle', 'Symposium on Computers', 'Proceedings of the Symposium on Computers');

fixes('pages', '13', '13');
fixes('pages', '100-110', '100--110');
fixes('pages', '2---33', '2--33');
fixes('pages', '22—23', '22--23');
fixes('pages', '05---07', '5--7');

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

0 comments on commit cb0cf1f

Please sign in to comment.