@@ -783,13 +783,18 @@ DefMacroI('\@declaredoptions', undef, Tokens());
783783DefMacroI(' \@curroptions' , undef , undef );
784784DefMacroI(' \@unusedoptionlist' , undef , Tokens());
785785
786- DefConstructor(' \usepackage OptionalSemiverbatim Semiverbatim []' ,
787- " <?latexml package='#2' ?#1(options='#1 ')?>" ,
786+ DefConstructor(' \usepackage OptionalUndigested Semiverbatim []' ,
787+ " <?latexml package='#2' ?#1(options='#options ')?>" ,
788788 beforeDigest => sub { onlyPreamble(' \usepackage' ); },
789789 afterDigest => sub { my ($stomach , $whatsit ) = @_ ;
790- my $options = [TrimmedCommaList($whatsit -> getArg(1))];
790+ # approximate semiverbatim by reparsing the inner lists
791+ my $options = [map {
792+ my ($k , $v ) = split (/ =/ , $_ , 2);
793+ defined $v ? ($k . ' =' . join (" ," , TrimmedCommaList($v ))) : $k ;
794+ } TrimmedCommaList($whatsit -> getArg(1))];
795+ $whatsit -> setProperty(options => join (" ," , @$options ));
791796 my $packages = $whatsit -> getArg(2);
792- for my $pkg (split ( ' , ' , ToString( $packages ) )) {
797+ for my $pkg (TrimmedCommaList( $packages )) {
793798 $pkg =~ s /\s +// g ;
794799 next if !$pkg || $pkg =~ / ^%/ ;
795800 RequirePackage($pkg , options => $options ); }
@@ -802,7 +807,7 @@ DefConstructor('\RequirePackage OptionalSemiverbatim Semiverbatim []',
802807 afterDigest => sub { my ($stomach , $whatsit ) = @_ ;
803808 my $options = [TrimmedCommaList($whatsit -> getArg(1))];
804809 my $packages = $whatsit -> getArg(2);
805- for my $pkg (split ( ' , ' , ToString( $packages ) )) {
810+ for my $pkg (TrimmedCommaList( $packages )) {
806811 $pkg =~ s /\s +// g ;
807812 next if !$pkg || $pkg =~ / ^%/ ;
808813 RequirePackage($pkg , options => $options ); }
@@ -3961,20 +3966,29 @@ DefMacro('\lx@ifusebbl{}{}{}', sub {
39613966 if ((ref $bib_config ne ' ARRAY' ) || scalar (@$bib_config ) == 0) {
39623967 Info(' missing' , ' bib_config' , $gullet , " BIB_CONFIG was empty, ignoring bibliography phase." );
39633968 return ; }
3964- if ($$bib_config [0] eq ' bbl' ) {
3969+ my $allows_bbl = scalar (grep { $_ eq ' bbl' } @$bib_config );
3970+ my $allows_bib = scalar (grep { $_ eq ' bib' } @$bib_config );
3971+ # bbl flow
3972+ if ($allows_bbl && ($$bib_config [0] eq ' bbl' )) {
39653973 if (not $bbl_path ) {
3966- Info(' expected' , " bbl" , $_ [0], " Couldn't find bbl file, bibliography may be empty." );
3967- return Tokens(); }
3974+ if (!$allows_bib ) {
3975+ Info(' expected' , " bbl" , $_ [0], " Couldn't find bbl file, bibliography may be empty." );
3976+ return Tokens(); } }
39683977 else {
39693978 return $bbl_clause -> unlist; } }
3979+ # bib flow
3980+ return Tokens() unless $allows_bib ;
3981+ for my $bf (TrimmedCommaList($bib_files )) {
3982+ my $bib_path = FindFile($bf , type => ' bib' );
3983+ if (not $bib_path ) {
3984+ $missing_bibs .= ' ,' unless length ($missing_bibs ) == 0;
3985+ $missing_bibs .= $bf ; } }
3986+ if (length ($missing_bibs ) == 0 or not $bbl_path ) {
3987+ return $bib_clause -> unlist; }
39703988 else {
3971- for my $bf (split (' ,' , $bib_files )) {
3972- my $bib_path = FindFile($bf , type => ' bib' );
3973- if (not $bib_path ) {
3974- $missing_bibs .= ' ,' unless length ($missing_bibs ) == 0;
3975- $missing_bibs .= $bf ; } }
3976- if (length ($missing_bibs ) == 0 or not $bbl_path ) {
3977- return $bib_clause -> unlist; }
3989+ if (!$allows_bbl ) {
3990+ Info(' expected' , $missing_bibs , $_ [0], " Couldn't find all bib files, bibliography may be empty" );
3991+ return Tokens(); }
39783992 else {
39793993 Info(' expected' , $missing_bibs , $_ [0], " Couldn't find all bib files, using " . $jobname . " .bbl instead" );
39803994 return $bbl_clause -> unlist; } } });
0 commit comments