diff options
Diffstat (limited to 'pandoc-cs1')
-rwxr-xr-x | pandoc-cs1 | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -35,6 +35,38 @@ pandoc_filter sub { '@'.$1.'{'.$id, @data, '}'); + if ( ! $bibdata->get('author') ) { + my @authors; + for ( my $i = 1;; $i++ ) { + my ( $first, $last ); + if ( $i == 1 and $bibdata->get('first') ) { + $first = $bibdata->get("first$i"); + $bibdata->delete("first$i"); + } elsif ( $bibdata->get("first$i") ) { + $first = $bibdata->get('first'); + $bibdata->delete('first'); + } + if ( $i == 1 and $bibdata->get('last') ) { + $last = $bibdata->get('last'); + $bibdata->delete('last'); + } elsif ( $bibdata->get("last$i") ) { + $last = $bibdata->get("last$i"); + $bibdata->delete("last$i"); + } + if ( $first and $last ) { + push @authors, "$first {$last}"; + } elsif ($first) { + push @authors, $first; + } elsif ($last) { + push @authors, $last; + } else { + last; + } + } + if ( @authors > 0 ) { + $bibdata->set( 'author', join ( ' and ', @authors ) ); + }; + }; if ( $bibdata->type =~ /web/i ) { $bibdata->set_type('online'); if ( my $urldate = $bibdata->get('accessdate') ) { |