3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 13:59:47 +01:00

Factoids: add quick-and-dirty early version of :join() modifier with many broken edge cases

This commit is contained in:
Pragmatic Software 2020-06-03 20:47:18 -07:00
parent 128c3014c7
commit 20febe7ccd

View File

@ -467,6 +467,10 @@ sub select_item {
$settings{'trailing-punct'} = $1;
}
if ($mod =~ /^join\((.?)\)$/) {
$settings{'join'} = $1;
}
if ($mod eq 'comma') {
$settings{'comma'} = 1;
next;
@ -570,7 +574,10 @@ sub select_item {
return @choices if wantarray;
if ($settings{'enumerate'} or $settings{'comma'}) {
if (exists $settings{'join'}) {
my $sep = $settings{'join'};
$item = join $sep, @choices;
} elsif ($settings{'enumerate'} or $settings{'comma'}) {
$item = join ', ', @choices;
$item =~ s/(.*), /$1 and / if $settings{'enumerate'};
} else {