aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-11-13 01:53:19 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-11-13 01:53:21 +0100
commit963a0d86a501ab3b1ed200857e2e5510e905a1d3 (patch)
tree7aa608e84e62008ce0e298e8160fd5ea03ee1380
parentc6888f6ded05885e2572cb1bfac84e4a6b99f8ff (diff)
downloadrf-963a0d86a501ab3b1ed200857e2e5510e905a1d3.tar.gz
implement naive 'or' interpolationor
It is naive because it only works if the first field is processed before the second -- i.e. the first letter comes before the other in the alphabet.
-rwxr-xr-xrf2
1 files changed, 2 insertions, 0 deletions
diff --git a/rf b/rf
index 0cf92a4..0d3fe67 100755
--- a/rf
+++ b/rf
@@ -169,6 +169,7 @@ sub fmt {
my $val = $ref{lc $fld};
$val = join '; ', @$val if lc $fld eq 'a';
$val = fmtl($val) if $fld eq 'A';
+ next if $fmt =~ s/\{([^{}%]*)%\Q$fld\E\|%[Aacdmnpqtwy]([^{}]*)}/$1$val$2/g;
if ($val =~ /[.,?!]$/) { # fix double punctuation
next if $fmt =~ s/\{([^{}%]*)%\Q$fld\E[.,?!]?([^{}]*)}/$1$val$2/g;
$fmt =~ s/%\Q$fld\E[.,?!]?/$val/g
@@ -178,6 +179,7 @@ sub fmt {
}
} else { # remove escape syntax after failed interpolation
no warnings;
+ next if $fmt =~ s/\{([^{}%]*)%\Q$fld\E\|(%[Aacdmnpqtwy])([^{}]*)}/$1$2$3/g;
next if $fmt =~ s/\{([^{}%]*)%\Q$fld\E([^{}]*)}[.,?!:;]?//g;
$fmt =~ s/%\Q$fld\E[.,?!:;]?//g;
}