Skip to content

Commit

Permalink
#76 swap
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Mar 15, 2024
1 parent 3f1e8fd commit 889c166
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bibcop.pl
Expand Up @@ -531,6 +531,12 @@ sub entry_fix {
my $tags = $blessed{$type};
my %allowed = map { $_ => 1 } @$tags;
my @lines;
if (exists $entry{'booktitle'} and $entry{':type'} eq 'article') {
$entry{'journal'} = $entry{'booktitle'};
}
if (exists $entry{'journal'} and $entry{':type'} eq 'inproceedings') {
$entry{'booktitle'} = $entry{'journal'};
}
foreach my $tag (keys %entry) {
if ($tag =~ /^:/) {
next;
Expand Down
4 changes: 4 additions & 0 deletions perl-tests/entry_fixing.pl
Expand Up @@ -31,9 +31,13 @@ package bibcop;

fixes_entry({':name' => 'knuth78', ':type' => 'book', 'title' => 'The TeX Book'}, "\@book{knuth78,\n title = {{The TeX Book}},\n}\n\n");
fixes_entry({':name' => 'k', ':type' => 'article', 'title' => 'Book', 'pages' => ''}, "\@article{k,\n title = {{Book}},\n}\n\n");

my $today = localtime->strftime('%d-%m-%Y');
fixes_entry({':name' => 'f', ':type' => 'misc', 'url' => 'http://google.com'}, "\@misc{f,\n howpublished = {\\url{http://google.com}},\n note = {[Online; accessed $today]},\n}\n\n");

fixes_entry({':name' => 'f', ':type' => 'article', 'booktitle' => 'ONE'}, "\@article{f,\n journal = {{ONE}},\n}\n\n");
fixes_entry({':name' => 'f', ':type' => 'inproceedings', 'journal' => 'ONE'}, "\@inproceedings{f,\n booktitle = {{Proceedings of the ONE}},\n}\n\n");

sub fixes_entry {
my ($hash, $expected) = @_;
my %entry = %$hash;
Expand Down

0 comments on commit 889c166

Please sign in to comment.