texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/Converter.pm (output, output


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/Converter.pm (output, output_no_split): remove calls to set_global_document_commands(), it is better if converters set the global commands on a case per case basis.
Date: Mon, 06 Sep 2021 10:57:00 -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 34c9815  * tp/Texinfo/Convert/Converter.pm (output, output_no_split): 
remove calls to set_global_document_commands(), it is better if converters set 
the global commands on a case per case basis.
34c9815 is described below

commit 34c9815c6e651b8de28198aadf7b2ba415cab31e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Sep 6 16:56:52 2021 +0200

    * tp/Texinfo/Convert/Converter.pm (output, output_no_split): remove
    calls to set_global_document_commands(), it is better if converters
    set the global commands on a case per case basis.
    
    * tp/Texinfo/Convert/Info.pm (_info_header),
    tp/Texinfo/Convert/Plaintext.pm (get_informative_global_commands):
    pass @informative_global_commands to with
    get_informative_global_commands() to limit the vairables on which
    set_global_document_commands() is used in Texinfo::Convert::Info
    _info_header().
    
    * tp/Texinfo/Convert/Plaintext.pm (%contents_commands): remove unused
    variable.
    
    * tp/Texinfo/Convert/Plaintext.pm (new_formatter): access 'frenchspacing'
    through get_conf(), and not ->{'conf'}.
    
    * tp/Texinfo/Convert/Plaintext.pm (@informative_global_commands,
    %formatting_misc_commands): remove from @informative_global_commands
    the @-commands that are not used through configuration or
    translation.  Put @*contents commands in %formatting_misc_commands
    such that they are taken into account, even if not in
    @informative_global_commands anymore.
---
 ChangeLog                       | 26 ++++++++++++++++++++++++++
 tp/Texinfo/Convert/Converter.pm |  8 --------
 tp/Texinfo/Convert/Info.pm      |  5 +++--
 tp/Texinfo/Convert/Plaintext.pm | 26 +++++++++++++-------------
 4 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2ca674b..b03b42f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
 2021-09-06  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Convert/Converter.pm (output, output_no_split): remove
+       calls to set_global_document_commands(), it is better if converters
+       set the global commands on a case per case basis.
+
+       * tp/Texinfo/Convert/Info.pm (_info_header),
+       tp/Texinfo/Convert/Plaintext.pm (get_informative_global_commands):
+       pass @informative_global_commands to with
+       get_informative_global_commands() to limit the vairables on which
+       set_global_document_commands() is used in Texinfo::Convert::Info
+       _info_header().
+
+       * tp/Texinfo/Convert/Plaintext.pm (%contents_commands): remove unused
+       variable.
+
+       * tp/Texinfo/Convert/Plaintext.pm (new_formatter): access 
'frenchspacing'
+       through get_conf(), and not ->{'conf'}.
+
+       * tp/Texinfo/Convert/Plaintext.pm (@informative_global_commands,
+       %formatting_misc_commands): remove from @informative_global_commands
+       the @-commands that are not used through configuration or
+       translation.  Put @*contents commands in %formatting_misc_commands
+       such that they are taken into account, even if not in
+       @informative_global_commands anymore.
+
+2021-09-06  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Convert/TexinfoXML.pm (format_header): remove document
        wide xml:lang texinfo element attribute as it does not corresponds to
        the document language settings in Texinfo which should be done with
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index ded6963..608e903 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -735,12 +735,6 @@ sub output($$)
   $self->_set_outfile();
   return undef unless $self->_create_destination_directory();
 
-  # do that now to have it available for formatting
-  # NOTE this calls Convert::Converter::_informative_command on all the 
-  # @informative_global commands.
-  # Thus sets among others language and encodings.
-  $self->set_global_document_commands(-1);
-
   if ($self->get_conf('USE_NODES')) {
     $elements = Texinfo::Structuring::split_by_node($root);
   } else {
@@ -1202,8 +1196,6 @@ sub output_no_split($$)
     }
   }
 
-  $self->set_global_document_commands(-1);
-
   if ($self->get_conf('USE_NODES')) {
     return $self->convert_document_nodes($root, $fh);
   } else {
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index cb1a156..14fd709 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -330,7 +330,8 @@ sub _info_header($)
   # commands in the document.  It may not correspond to the
   # intent of the author if the global commands appears late
   # in the document.  However this is the best guess we can do.
-  $self->set_global_document_commands(1);
+  my @informative_global_commands = $self->get_informative_global_commands();
+  $self->set_global_document_commands(1, \@informative_global_commands);
   if ($self->{'extra'} and $self->{'extra'}->{'copying'}) {
     print STDERR "COPYING HEADER\n" if ($self->get_conf('DEBUG'));
     $self->{'in_copying_header'} = 1;
@@ -340,7 +341,7 @@ sub _info_header($)
     $result .= $self->_footnotes();
     delete $self->{'in_copying_header'};
   }
-  $self->set_global_document_commands(0);
+  $self->set_global_document_commands(0, \@informative_global_commands);
 
   if ($self->{'parser_info'}->{'dircategory_direntry'}) {
     $self->{'ignored_commands'}->{'direntry'} = 0;
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 3f69e19..96d0faa 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -60,15 +60,22 @@ my %formatting_misc_commands = 
%Texinfo::Convert::Text::formatting_misc_commands
 
 my $NO_NUMBER_FOOTNOTE_SYMBOL = '*';
 
+# documentlanguage is used through gdt().
 my @informative_global_commands = ('paragraphindent', 'firstparagraphindent',
-'frenchspacing', 'documentencoding', 'footnotestyle', 'documentlanguage',
-'contents', 'shortcontents', 'summarycontents', 'deftypefnnewline');
+'frenchspacing', 'footnotestyle', 'documentlanguage', 'deftypefnnewline');
 
 my %informative_commands;
 foreach my $informative_command (@informative_global_commands) {
   $informative_commands{$informative_command} = 1;
 }
 
+# used to pass to Texinfo::Convert::Info
+sub get_informative_global_commands($)
+{
+  my $self = shift;
+  return @informative_global_commands;
+}
+
 my %no_brace_commands = %Texinfo::Common::no_brace_commands;
 my %brace_no_arg_commands;
 foreach my $command (keys (%Texinfo::Common::brace_commands)) {
@@ -99,8 +106,8 @@ my %letter_no_arg_commands = 
%Texinfo::Common::letter_no_arg_commands;
 
 foreach my $kept_command(keys (%informative_commands),
   keys (%default_index_commands),
-  'verbatiminclude', 'insertcopying', 
-  'listoffloats', 'printindex', ) {
+  'verbatiminclude', 'insertcopying', 'contents', 'shortcontents',
+  'summarycontents', 'listoffloats', 'printindex', ) {
   $formatting_misc_commands{$kept_command} = 1;
 }
 
@@ -356,13 +363,6 @@ sub push_top_formatter($$)
   $self->{'formatters'}->[-1]->{'_top_formatter'} = 1;
 }
 
-
-my %contents_commands = (
- 'contents' => 1,
- 'shortcontents' => 1,
- 'summarycontents' => 1,
-);
-
 sub converter_defaults($$)
 {
   return %defaults;
@@ -591,7 +591,7 @@ sub new_formatter($$;$)
          'indent_level'      => 
$self->{'format_context'}->[-1]->{'indent_level'}, 
   };
   $container_conf->{'frenchspacing'} = 1 
-    if ($self->{'conf'}->{'frenchspacing'} eq 'on');
+    if ($self->get_conf('frenchspacing') eq 'on');
   $container_conf->{'counter'} 
     = $self->{'text_element_context'}->[-1]->{'counter'}
       if (defined($self->{'text_element_context'}->[-1]->{'counter'}));
@@ -641,7 +641,7 @@ sub new_formatter($$;$)
   my $formatter = {'container' => $container, 'upper_case' => 0,
                    'font_type_stack' => [{}],
                    'w' => 0, 'type' => $type,
-              'frenchspacing_stack' => [$self->{'conf'}->{'frenchspacing'}],
+              'frenchspacing_stack' => [$self->get_conf('frenchspacing')],
               'suppress_styles' => $conf->{'suppress_styles'}};
 
   if ($type eq 'unfilled') {



reply via email to

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