Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set size for which parserPopUp prints an inline string. #1112

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions macros/parsers/parserPopUp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ =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 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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -437,15 +447,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 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) {
Expand Down