From 963a0d86a501ab3b1ed200857e2e5510e905a1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 13 Nov 2020 01:53:19 +0100 Subject: implement naive 'or' interpolation 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. --- rf | 2 ++ 1 file changed, 2 insertions(+) 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; } -- cgit v1.2.3