From ec71bc3fe7afce9bec5d32ea85e0edb52d8de605 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Tue, 3 Sep 2024 07:01:16 -0600 Subject: [PATCH] Add option to set size for which parserPopUp prints an inline string. In hardcopy output, allow the size (number of characters) that an inline string [A/B/C] vs a bullet list is printed to be configurable via a new option inlineSize. --- macros/parsers/parserPopUp.pl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/macros/parsers/parserPopUp.pl b/macros/parsers/parserPopUp.pl index 8e67664a6..fff9da66b 100644 --- a/macros/parsers/parserPopUp.pl +++ b/macros/parsers/parserPopUp.pl @@ -137,6 +137,14 @@ =head1 DESCRIPTION unnecessary in a static output format.) Default: 1, except 0 for DropDownTF. +=item C number >>> + +In PDF output, this controls break point between printing the list of +options as an inline list [A/B/C] or multiline bullet list. If the total +number of characters (of all items combined) is greater than this setting, +or an item contains a '[', '/', or ']' character, then the list of options +is printed as a bullet list, otherwise an inline list is used. Default: 25 + =back To insert the drop-down into the problem text when using PGML: @@ -231,6 +239,7 @@ sub new { choices => $choices, placeholder => $options{placeholder} // '', showInStatic => $options{showInStatic} // 1, + inlineSize => $options{inlineSize} // 25, values => $options{values} // [], noindex => $options{noindex} // 0 }, $class; @@ -437,15 +446,13 @@ sub MENU { $menu = qq(); } } elsif ($main::displayMode eq "TeX" && $self->{showInStatic}) { - # if the total number of characters is not more than - # 30 and not containing / or ] then we print out + # Unless the total number of characters is more than the inlineSize + # setting (default 25), or contains [, ], or / then we print out # the select as a string: [A/B/C] - if (length(join('', @list)) < 25 - && !grep(/(\/|\[|\])/, @list)) - { + unless (length(join('', @list)) > $self->{inlineSize} || grep(/(\/|\[|\])/, @list)) { $menu = '[' . join('/', map { $self->quoteTeX($_) } @list) . ']'; } else { - #otherwise we print a bulleted list + # Otherwise we print a bulleted list. $menu = '\par\vtop{\def\bitem{\hbox\bgroup\indent\strut\textbullet\ \ignorespaces}\let\eitem=\egroup'; $menu = "\n" . $menu . "\n"; foreach my $option (@list) {