texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/texi2any.pl (%ignored_formats, %converter_fo


From: Patrice Dumas
Subject: branch master updated: * tp/texi2any.pl (%ignored_formats, %converter_format_format_name) (_format_expanded_formats, set_format): do not set default expanded formats in set_format, but after the format has been setup. Keep track of ignored formats to be able to remove them from defaults expanded formats at that time.
Date: Sat, 05 Oct 2024 05:23:29 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new bd493bb021 * tp/texi2any.pl (%ignored_formats, 
%converter_format_format_name) (_format_expanded_formats, set_format): do not 
set default expanded formats in set_format, but after the format has been 
setup.  Keep track of ignored formats to be able to remove them from defaults 
expanded formats at that time.
bd493bb021 is described below

commit bd493bb021fece4e2eca66aa096463f613f38891
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 25 10:47:02 2024 +0200

    * tp/texi2any.pl (%ignored_formats, %converter_format_format_name)
    (_format_expanded_formats, set_format): do not set default expanded
    formats in set_format, but after the format has been setup.  Keep
    track of ignored formats to be able to remove them from defaults
    expanded formats at that time.
---
 ChangeLog                       |  8 ++++
 tp/Texinfo/Convert/Converter.pm |  3 +-
 tp/texi2any.pl                  | 82 +++++++++++++++++++++++------------------
 3 files changed, 55 insertions(+), 38 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 70ccb5f923..db4079cb33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-08-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/texi2any.pl (%ignored_formats, %converter_format_format_name)
+       (_format_expanded_formats, set_format): do not set default expanded
+       formats in set_format, but after the format has been setup.  Keep
+       track of ignored formats to be able to remove them from defaults
+       expanded formats at that time.
+
 2024-08-24  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/IXINSXML.pm (%defaults): do not set
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 8c81ba6804..8ce3e3cd61 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -2164,8 +2164,7 @@ These options are Texinfo customization options and a few 
other options that can
 be passed to the converter. Most of the customization options
 are described in the Texinfo manual or in the customization API manual.
 Those customization options, when appropriate, override the document content.
-B<TODO what about the other options (all are used in converters). Describe
-in converter_defaults?>
+B<TODO what about the other options?>
 
 The C<converter> function returns a converter object (a blessed hash
 reference) after checking the options and performing some initializations.
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index ae54de3239..97bdece316 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -703,10 +703,6 @@ my $cmdline_options = { 'CSS_FILES' => \@css_files,
                         'EXPANDED_FORMATS' => \@expanded_formats };
 
 my $format = 'info';
-# this is the format associated with the output format, which is replaced
-# when the output format changes.  It may also be removed if there is the
-# corresponding --no-ifformat.
-my $default_expanded_format = [ $format ];
 my @conf_dirs = ();
 my @prepend_dirs = ();
 
@@ -759,6 +755,7 @@ if (defined($set_translations_encoding)
 
 
 # Parse command line
+my %ignored_formats;
 
 sub set_expansion($$) {
   my $region = shift;
@@ -766,10 +763,10 @@ sub set_expansion($$) {
   $set = 1 if (!defined($set));
   if ($set) {
     add_to_option_list('EXPANDED_FORMATS', [$region]);
+    delete $ignored_formats{$region};
   } else {
     remove_from_option_list('EXPANDED_FORMATS', [$region]);
-    @{$default_expanded_format}
-       = grep {$_ ne $region} @{$default_expanded_format};
+    $ignored_formats{$region} = 1;
   }
 }
 
@@ -910,34 +907,6 @@ sub set_format($;$$)
     if ($format_from_command_line and $do_not_override_command_line) {
       $new_output_format = $previous_format;
     } else {
-      my $converter_format;
-      my $expanded_region;
-
-      if ($formats_table{$new_output_format}->{'texi2dvi_format'}) {
-        $call_texi2dvi = 1;
-        push @texi2dvi_args, '--'.$new_output_format;
-        $converter_format = 'tex';
-      } elsif ($formats_table{$new_output_format}->{'converted_format'}) {
-        $converter_format
-          = $formats_table{$new_output_format}->{'converted_format'};
-      } else {
-        $converter_format = $new_output_format;
-      }
-
-      if ($converter_format_expanded_region_name{$converter_format}) {
-        $expanded_region
-          = $converter_format_expanded_region_name{$converter_format};
-      } else {
-        $expanded_region = $converter_format;
-      }
-
-      if ($Texinfo::Common::texinfo_output_formats{$expanded_region}) {
-        if ($expanded_region eq 'plaintext') {
-          $default_expanded_format = [$expanded_region, 'info'];
-        } else {
-          $default_expanded_format = [$expanded_region];
-        }
-      }
       $format_from_command_line = 1
         unless ($do_not_override_command_line);
     }
@@ -945,6 +914,43 @@ sub set_format($;$$)
   return $new_output_format;
 }
 
+sub _format_expanded_formats($)
+{
+  my $new_output_format = shift;
+
+  my $default_expanded_formats = {};
+
+  my $converter_format;
+  my $expanded_region;
+
+  if ($formats_table{$new_output_format}->{'texi2dvi_format'}) {
+    $call_texi2dvi = 1;
+    push @texi2dvi_args, '--'.$new_output_format;
+    $converter_format = 'tex';
+  } elsif ($formats_table{$new_output_format}->{'converted_format'}) {
+    $converter_format
+      = $formats_table{$new_output_format}->{'converted_format'};
+  } else {
+    $converter_format = $new_output_format;
+  }
+
+  if ($converter_format_expanded_region_name{$converter_format}) {
+    $expanded_region
+      = $converter_format_expanded_region_name{$converter_format};
+  } else {
+    $expanded_region = $converter_format;
+  }
+
+  if ($Texinfo::Common::texinfo_output_formats{$expanded_region}) {
+    if ($expanded_region eq 'plaintext') {
+      $default_expanded_formats = {$expanded_region => 1, 'info' => 1};
+    } else {
+      $default_expanded_formats = {$expanded_region => 1};
+    }
+  }
+  return $default_expanded_formats;
+}
+
 sub _get_converter_default($)
 {
   my $option = shift;
@@ -1308,7 +1314,7 @@ if (defined($set_translations_encoding)
 }
 
 # Change some options depending on the settings of other ones set formats
-sub process_config {
+sub process_config($) {
   my $conf = shift;
 
   if (defined($conf->{'TEXINFO_OUTPUT_FORMAT'})) {
@@ -1547,7 +1553,11 @@ if (get_conf('SPLIT') and 
!$formats_table{$converted_format}->{'split'}) {
   set_from_cmdline('SPLIT', '');
 }
 
-add_to_option_list('EXPANDED_FORMATS', $default_expanded_format);
+my $default_expanded_formats = _format_expanded_formats($format);
+foreach my $ignored_format (keys(%ignored_formats)) {
+  delete $default_expanded_formats->{$ignored_format};
+}
+add_to_option_list('EXPANDED_FORMATS', 
[sort(keys(%$default_expanded_formats))]);
 
 if (defined($formats_table{$converted_format}->{'module'})) {
   # Speed up initialization by only loading the module we need.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]