aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-11-10 23:30:56 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-11-10 23:31:04 +0100
commit87c49bd96602bf44aaf255adc237a22236c1290b (patch)
tree445886b7f814b98f276e9c45f344c821dd017fc6
parent80b1d2e0e7ba2800924f70c45ce567ae8d8a16b2 (diff)
downloadrf-87c49bd96602bf44aaf255adc237a22236c1290b.tar.gz
support multiple authors; show full names in reflist
-rw-r--r--rf.pl29
1 files changed, 19 insertions, 10 deletions
diff --git a/rf.pl b/rf.pl
index b2fe726..86345dd 100644
--- a/rf.pl
+++ b/rf.pl
@@ -28,7 +28,11 @@ while (<>) {
if ($fld eq 'a') {
$i++ if not $author_last;
push @lines, ".R! $i";
- $refs[$i]{$fld} = $def;
+ if (defined $refs[$i]{a}) {
+ $refs[$i]{a} = "; $def";
+ } else {
+ $refs[$i]{a} = $def;
+ }
$author_last = 1;
next;
} elsif ($fld =~ /[cdnpqtwy]/) {
@@ -75,7 +79,7 @@ for (@lines) {
# Reference definition
if (/^\.R! (\d+)/) {
- print fmt($format_list, $1) . "\n";
+ print fmt($format_list, $1, 1) . "\n";
next;
}
@@ -85,13 +89,13 @@ for (@lines) {
}
sub fmt {
- my ($fmt, $i) = @_;
+ my ($fmt, $i, $full) = @_;
my %ref = %{$refs[$i]};
for my $fld (split //, 'acdnpqtwy') {
if ($ref{$fld}) {
no warnings;
my $val = $ref{$fld};
- $val = fmta($val) if $fld eq 'a';
+ $val = fmta($val) if $fld eq 'a' and not $full;
$fmt =~ s/\{(.*?)%$fld(.*?)}/$1$val$3/g;
$fmt =~ s/%$fld/$val/g;
} else {
@@ -107,13 +111,18 @@ sub fmt {
}
sub fmta {
- my ($name) = @_;
- if ($name =~ /(.*?),/) {
- return $1;
- } else {
- $name =~ s/(.*?)\s/$1/;
- return $name;
+ my ($a) = @_;
+ my $r;
+ for my $name (split /; /, $a) {
+ if ($name =~ /(.*?),/) {
+ $r .= ", $1";
+ } else {
+ $name =~ s/(.*?)\s/$1/;
+ return ", $name";
+ }
}
+ $r =~ s/^, //;
+ return $r;
}
sub likeness {