Skip to content

Commit

Permalink
#44 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Aug 19, 2023
1 parent 35279e2 commit adeb46e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion bibcop.pl
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,23 @@ sub fix_pages {
if ($value =~ /^[1-9][0-9]*$/) {
return $value;
}
my ($left, $right) = split(/---|--|-|—|\s/, $value);
my ($left, $right) = split(/---|--|-|—|–|\s/, $value);
$left =~ s/^0+//g;
$right =~ s/^0+//g;
if ($left eq '') {
$left = $right;
}
if ($right eq '') {
$right = $left;
}
if ($left + 0 gt $right + 0) {
my $tmp = $left;
$left = $right;
$right = $tmp;
}
if ($left eq $right) {
return $left;
}
return $left . '--' . $right;
}

Expand Down
3 changes: 3 additions & 0 deletions perl-tests/fixing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ package bibcop;
fixes('booktitle', 'Symposium on Computers', 'Proceedings of the Symposium on Computers');

fixes('pages', '13', '13');
fixes('pages', '13-', '13');
fixes('pages', '196--230', '196--230');
fixes('pages', '100-110', '100--110');
fixes('pages', '117–128', '117--128');
fixes('pages', '2---33', '2--33');
fixes('pages', '22—23', '22--23');
fixes('pages', '05---07', '5--7');
fixes('pages', '42---13', '13--42');

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

0 comments on commit adeb46e

Please sign in to comment.