Skip to content

Commit

Permalink
Add option to set size for which parserPopUp prints an inline string.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
somiaj committed Sep 3, 2024
1 parent cd49bc1 commit ec71bc3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions macros/parsers/parserPopUp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ =head1 DESCRIPTION
unnecessary in a static output format.) Default: 1, except 0 for
DropDownTF.
=item C<S<< inlineSize => 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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -437,15 +446,13 @@ sub MENU {
$menu = qq(<fillin name="$name"/>);
}
} 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) {
Expand Down

0 comments on commit ec71bc3

Please sign in to comment.