diff --git a/bibcop.pl b/bibcop.pl index 90c0572..195b7b2 100755 --- a/bibcop.pl +++ b/bibcop.pl @@ -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; diff --git a/perl-tests/entry_fixing.pl b/perl-tests/entry_fixing.pl index b6af831..e81c0c2 100755 --- a/perl-tests/entry_fixing.pl +++ b/perl-tests/entry_fixing.pl @@ -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;