diff options
author | John Ankarström <john@ankarstrom.se> | 2020-11-13 01:53:19 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2020-11-13 01:53:21 +0100 |
commit | 963a0d86a501ab3b1ed200857e2e5510e905a1d3 (patch) | |
tree | 7aa608e84e62008ce0e298e8160fd5ea03ee1380 | |
parent | c6888f6ded05885e2572cb1bfac84e4a6b99f8ff (diff) | |
download | rf-or.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-x | rf | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -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; } |