From a1584962ebc31ab920ba5ae5af9581d3796ee061 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 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/macros/parsers/parserPopUp.pl b/macros/parsers/parserPopUp.pl index 32b64e908..929b64a7f 100644 --- a/macros/parsers/parserPopUp.pl +++ b/macros/parsers/parserPopUp.pl @@ -137,6 +137,15 @@ =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 or equal to +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 +240,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 +447,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 greater than or equal to 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) {