Skip to content

Commit

Permalink
#52 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 1, 2023
1 parent c942307 commit bd0ab03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bibcop.pl
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,17 @@ sub fix_pages {
return $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;
}
$left =~ s/^0+//g;
$right =~ s/^0+//g;
if ($left !~ /^[0-9]*$/ or $right !~ /^[0-9]*$/) {
return $value;
}
if ($left + 0 gt $right + 0) {
my $tmp = $left;
$left = $right;
Expand Down
4 changes: 4 additions & 0 deletions perl-tests/fixing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ package bibcop;

fixes('pages', '13', '13');
fixes('pages', '13-', '13');
fixes('pages', '13--', '13');
fixes('pages', '-13', '13');
fixes('pages', '--13', '13');
fixes('pages', 'abc1', 'abc1');
fixes('pages', '196--230', '196--230');
fixes('pages', '100-110', '100--110');
fixes('pages', '117–128', '117--128');
Expand Down

0 comments on commit bd0ab03

Please sign in to comment.