Skip to content

Commit 0666f64

Browse files
committed
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.
1 parent 94bac43 commit 0666f64

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

macros/parsers/parserPopUp.pl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ =head1 DESCRIPTION
137137
unnecessary in a static output format.) Default: 1, except 0 for
138138
DropDownTF.
139139
140+
=item C<S<< inlineSize => number >>>
141+
142+
In PDF output, this controls break point between printing the list of
143+
options as an inline list [A/B/C] or multiline bullet list. If the total
144+
number of characters (of all items combined) is greater than or equal to
145+
this setting, or an item contains a '[', '/', or ']' character, then the
146+
list of options is printed as a bullet list, otherwise an inline list is
147+
used. Default: 25
148+
140149
=back
141150
142151
To insert the drop-down into the problem text when using PGML:
@@ -231,6 +240,7 @@ sub new {
231240
choices => $choices,
232241
placeholder => $options{placeholder} // '',
233242
showInStatic => $options{showInStatic} // 1,
243+
inlineSize => $options{inlineSize} // 25,
234244
values => $options{values} // [],
235245
noindex => $options{noindex} // 0
236246
}, $class;
@@ -437,15 +447,13 @@ sub MENU {
437447
$menu = qq(<fillin name="$name"/>);
438448
}
439449
} elsif ($main::displayMode eq "TeX" && $self->{showInStatic}) {
440-
# if the total number of characters is not more than
441-
# 30 and not containing / or ] then we print out
450+
# Unless the total number of characters is greater than or equal to the
451+
# inlineSize setting (default 25), or contains [, ], or / then we print out
442452
# the select as a string: [A/B/C]
443-
if (length(join('', @list)) < 25
444-
&& !grep(/(\/|\[|\])/, @list))
445-
{
453+
unless (length(join('', @list)) >= $self->{inlineSize} || grep(/(\/|\[|\])/, @list)) {
446454
$menu = '[' . join('/', map { $self->quoteTeX($_) } @list) . ']';
447455
} else {
448-
#otherwise we print a bulleted list
456+
# Otherwise we print a bulleted list.
449457
$menu = '\par\vtop{\def\bitem{\hbox\bgroup\indent\strut\textbullet\ \ignorespaces}\let\eitem=\egroup';
450458
$menu = "\n" . $menu . "\n";
451459
foreach my $option (@list) {

0 commit comments

Comments
 (0)