texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Set novalidate in main program and use common cod


From: Patrice Dumas
Subject: branch master updated: Set novalidate in main program and use common code to set language
Date: Sun, 16 Jan 2022 09:47:48 -0500

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 bdfeb6f76d Set novalidate in main program and use common code to set 
language
bdfeb6f76d is described below

commit bdfeb6f76d9aff68c29c581a94f55d80c68e14ab
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 16 15:44:22 2022 +0100

    Set novalidate in main program and use common code to set language
    
    * tp/Texinfo/Common.pm (%default_parser_common_customization),
    tp/Texinfo/ParserNonXS.pm (_set_global_informations),
    tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser, parse_texi_file)
    (parse_texi_piece, parse_texi_text),
    tp/Texinfo/Structuring.pm (set_menus_node_directions, nodes_tree)
    (associate_internal_references),
    tp/texi2any.pl: do not set novalidate in parser info, instead set it
    in main program in main configuration.  Remove novalidate from
    parser options and inputs.
    
    * tp/Texinfo/Common.pm (_informative_command_value)
    (set_informative_command_value, _in_preamble)
    (set_global_document_command), tp/Texinfo/Convert/Converter.pm
    (set_global_document_commands),
    tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm,
    tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
    tp/texi2any.pl: extract set_global_document_command from
    set_global_document_commands in Texinfo::Convert::Converter
    and move it, with set_informative_command_value to Texinfo::Common.
    Use that code to set documentlanguage in main program configuration.
---
 ChangeLog                            |  25 ++++++
 tp/Texinfo/Common.pm                 | 142 ++++++++++++++++++++++++++++++++++-
 tp/Texinfo/Convert/Converter.pm      | 101 ++-----------------------
 tp/Texinfo/Convert/DocBook.pm        |   2 +-
 tp/Texinfo/Convert/HTML.pm           |   4 +-
 tp/Texinfo/Convert/LaTeX.pm          |   2 +-
 tp/Texinfo/Convert/Plaintext.pm      |   2 +-
 tp/Texinfo/ParserNonXS.pm            |  30 +++-----
 tp/Texinfo/Structuring.pm            |  10 +--
 tp/Texinfo/XS/parsetexi/Parsetexi.pm |  19 +----
 tp/t/test_utils.pl                   |   7 +-
 tp/texi2any.pl                       |  24 +++---
 12 files changed, 212 insertions(+), 156 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b121697792..ac31123b50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,31 @@
        can be used for alignment in multitables.
        * tp/t/21multitable.t (multitable_figure_space): New test.
 
+2022-01-16  Patrice Dumas  <pertusus@free.fr>
+
+       Set novalidate in main program and use common code to set language
+
+       * tp/Texinfo/Common.pm (%default_parser_common_customization),
+       tp/Texinfo/ParserNonXS.pm (_set_global_informations),
+       tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser, parse_texi_file)
+       (parse_texi_piece, parse_texi_text),
+       tp/Texinfo/Structuring.pm (set_menus_node_directions, nodes_tree)
+       (associate_internal_references),
+       tp/texi2any.pl: do not set novalidate in parser info, instead set it
+       in main program in main configuration.  Remove novalidate from
+       parser options and inputs.
+
+       * tp/Texinfo/Common.pm (_informative_command_value)
+       (set_informative_command_value, _in_preamble)
+       (set_global_document_command), tp/Texinfo/Convert/Converter.pm
+       (set_global_document_commands),
+       tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm,
+       tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
+       tp/texi2any.pl: extract set_global_document_command from
+       set_global_document_commands in Texinfo::Convert::Converter
+       and move it, with set_informative_command_value to Texinfo::Common.
+       Use that code to set documentlanguage in main program configuration.
+
 2022-01-16  Patrice Dumas  <pertusus@free.fr>
 
        * po_document/POTFILES.in: add tp/Texinfo/Translations.pm.
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 7a5350c5ba..b5ae4cc879 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -103,7 +103,6 @@ my %default_parser_common_customization = (
   'documentlanguage' => undef,  # not 'en' as it is better to specify that 
there is no
                                 # need for translation since the strings are 
in english
                                 # rather than ask for translations to en
-  'novalidate' => undef,   # --no-validate
   'EXPANDED_FORMATS' => [],
   'DEBUG' => 0,     # if >= 10, tree is printed in texi2any.pl after parsing.
                     # If >= 100 tree is printed every line.
@@ -1549,6 +1548,110 @@ sub locate_include_file($$)
   return $file;
 }
 
+sub _informative_command_value($)
+{
+  my $element = shift;
+
+  my $cmdname = $element->{'cmdname'};
+
+  if ($misc_commands{$cmdname} eq 'skipline') {
+    return 1;
+  } elsif (exists($element->{'extra'}->{'text_arg'})) {
+    return $element->{'extra'}->{'text_arg'};
+  } elsif ($element->{'extra'} and $element->{'extra'}->{'misc_args'}
+           and exists($element->{'extra'}->{'misc_args'}->[0])) {
+    return $element->{'extra'}->{'misc_args'}->[0];
+  }
+  return undef;
+}
+
+# REMARK documentencoding handling is not reverted by resetting
+# a value with set_conf, as the encodings are set using other
+# informations (possibly based on @documentencoding) in converter.
+sub set_informative_command_value($$)
+{
+  my $self = shift;
+  my $element = shift;
+
+  my $cmdname = $element->{'cmdname'};
+  $cmdname = 'shortcontents' if ($cmdname eq 'summarycontents');
+
+  my $value = _informative_command_value($element);
+  if (defined($value)) {
+    $self->set_conf($cmdname, $value);
+  }
+}
+
+sub _in_preamble($)
+{
+  my $element = shift;
+  my $current_element = $element;
+  while ($current_element->{'parent'}) {
+    if (defined($current_element->{'parent'}->{'type'})
+        and $current_element->{'parent'}->{'type'} eq 
'preamble_before_content') {
+      return 1;
+    }
+    $current_element = $current_element->{'parent'};
+  }
+  return 0;
+}
+
+# $COMMAND_LOCATION is 'last', 'preamble' or 'preamble_or_first'
+# 'preamble' means setting sequentially to the values in the preamble.
+# 'preamble_or_first'  means setting to the first value for the command
+# in the document if the first command is not in the preamble, else set
+# sequentially to the values in the preamble.
+# 'last' means setting to the last value for the command in the document.
+#
+# For unique command, the last may be considered to be the same as the first.
+#
+# Notice that the only effect is to use set_conf (directly or through
+# set_informative_command_value), no @-commands setting side effects are done
+# and associated customization variables are not set/reset either.
+sub set_global_document_command($$$$)
+{
+  my $self = shift;
+  my $global_commands_information = shift;
+  my $global_command = shift;
+  my $command_location = shift;
+
+  if ($command_location ne 'last' and $command_location ne 'preamble_or_first'
+      and $command_location ne 'preamble') {
+    warn "BUG: set_global_document_commands: unknown command_location: 
$command_location";
+  }
+
+  my $element;
+  if (defined($global_commands_information->{$global_command})
+      and ref($global_commands_information->{$global_command}) eq 'ARRAY') {
+    if ($command_location eq 'last') {
+      $element = $global_commands_information->{$global_command}->[-1];
+      set_informative_command_value($self, $element);
+    } else {
+      if ($command_location eq 'preamble_or_first'
+          and not 
_in_preamble($global_commands_information->{$global_command}->[0])) {
+        $element =
+          $global_commands_information->{$global_command}->[0];
+        set_informative_command_value($self, $element);
+      } else {
+        foreach my $command_element 
(@{$global_commands_information->{$global_command}}) {
+          if (_in_preamble($command_element)) {
+            $element = $command_element;
+            set_informative_command_value($self, $element);
+          } else {
+            last;
+          }
+        }
+      }
+    }
+  } elsif (defined($global_commands_information->{$global_command})) {
+    # unique command, first, preamble and last are the same
+    $element = $global_commands_information->{$global_command};
+    set_informative_command_value($self, $element);
+  }
+  return $element;
+}
+
+
 sub set_output_encodings($$)
 {
   my $configuration_informations = shift;
@@ -2976,6 +3079,43 @@ Remove the index @-command from the tree.
 Return numbered level of the tree sectioning I<$section>, as modified by
 raise/lowersections.
 
+=item $element = set_global_document_command($configuration_informations, 
$global_commands_information, $cmdname, $command_location)
+
+Set the Texinfo configuration option corresponding to I<$cmdname> in
+I<$configuration_informations>.  The I<$global_commands_information> should
+contain information about global commands in a Texinfo document, typically 
obtained
+from a parser, like L<Texinfo::Parser/$commands = 
global_commands_information($parser)>.
+I<$command_location> specifies where in the document the value should be taken 
from,
+for commands that may appear more than once. The possibilities are:
+
+=over
+
+=item last
+
+Set to the last value for the command.
+
+=item preamble
+
+Set sequentially to the values in the Texinfo preamble.
+
+=item preamble_or_first
+
+Set to the first value of the command if the first command is not
+in the Texinfo preamble, else set as with I<preamble>,
+sequentially to the values in the Texinfo preamble.
+
+=back
+
+The I<$element> returned is the last element that was used to set the
+configuration value, or C<undef> if no configuration value was found.
+
+=item set_informative_command_value($configuration_informations, $element)
+
+Set the Texinfo configuration option corresponding to the tree element
+I<$element>.  The command associated to the tree element should be
+a command that sets some information, such as C<@documentlanguage>,
+C<@contents> or C<@footnotestyle> for example.
+
 =item set_output_encodings($configuration_informations, $parser_informations)
 
 If not already set, set C<OUTPUT_ENCODING_NAME> based on input file
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 79032d6c46..042c92db0c 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -919,41 +919,6 @@ sub create_destination_directory($$)
 #############################################################
 # useful methods for Converters.
 
-sub _informative_command_value($$)
-{
-  my $self = shift;
-  my $element = shift;
-
-  my $cmdname = $element->{'cmdname'};
-
-  if ($Texinfo::Common::misc_commands{$cmdname} eq 'skipline') {
-    return 1;
-  } elsif (exists($element->{'extra'}->{'text_arg'})) {
-    return $element->{'extra'}->{'text_arg'};
-  } elsif ($element->{'extra'} and $element->{'extra'}->{'misc_args'}
-           and exists($element->{'extra'}->{'misc_args'}->[0])) {
-    return $element->{'extra'}->{'misc_args'}->[0];
-  }
-  return undef;
-}
-
-# REMARK documentencoding handling is not reverted by resetting
-# a value with set_conf, as the encodings are set using other
-# informations (possibly based on @documentencoding) in converter.
-sub set_informative_command_value($$)
-{
-  my $self = shift;
-  my $element = shift;
-
-  my $cmdname = $element->{'cmdname'};
-  $cmdname = 'shortcontents' if ($cmdname eq 'summarycontents');
-
-  my $value = $self->_informative_command_value($element);
-  if (defined($value)) {
-    $self->set_conf($cmdname, $value);
-  }
-}
-
 # determine the default, with $INIT_CONF if set, or the default common
 # to all the converters
 sub _command_init($$)
@@ -969,33 +934,17 @@ sub _command_init($$)
   }
 }
 
-sub _in_preamble($)
-{
-  my $element = shift;
-  my $current_element = $element;
-  while ($current_element->{'parent'}) {
-    if (defined($current_element->{'parent'}->{'type'})
-        and $current_element->{'parent'}->{'type'} eq 
'preamble_before_content') {
-      return 1;
-    }
-    $current_element = $current_element->{'parent'};
-  }
-  return 0;
-}
-
 # $COMMANDS_LOCATION is 'before', 'last', 'preamble' or 'preamble_or_first'
 # 'before' means setting to the values before the document commands
 # (defaults and command-line).
 # 'preamble' means setting sequentially to the values in the preamble.
-# 'first_or_preamble'  means setting to the first value for the command
+# 'preamble_or_first'  means setting to the first value for the command
 # in the document if the first command is not in the preamble, else set
 # sequentially to the values in the preamble.
 # 'last' means setting to the last value for the command in the document.
 #
-# For unique command, the last may be considered to be the same as the first.
-#
 # Notice that the only effect is to use set_conf (directly or through
-# set_informative_command_value), no @-commands setting side effects are done
+# set_global_document_command), no @-commands setting side effects are done
 # and associated customization variables are not set/reset either.
 sub set_global_document_commands($$;$)
 {
@@ -1021,46 +970,17 @@ sub set_global_document_commands($$;$)
       $self->set_conf($global_command, _command_init($global_command, 
$init_conf));
     }
   } else {
-    if ($commands_location ne 'last' and $commands_location ne 
'preamble_or_first'
-        and $commands_location ne 'preamble') {
-      warn "BUG: set_global_document_commands: unknown commands_location: 
$commands_location";
-    }
     foreach my $global_command (@{$selected_commands}) {
-      my $element;
       if ($self->get_conf('DEBUG')) {
-        print STDERR "SET_global_document_commands($commands_location) 
$global_command\n";
-      }
-      if (defined($self->{'global_commands'}->{$global_command})
-          and ref($self->{'global_commands'}->{$global_command}) eq 'ARRAY') {
-        if ($commands_location eq 'last') {
-          $element = $self->{'global_commands'}->{$global_command}->[-1];
-          $self->set_informative_command_value($element);
-        } else {
-          if ($commands_location eq 'preamble_or_first'
-              and not 
_in_preamble($self->{'global_commands'}->{$global_command}->[0])) {
-            $element =
-              $self->{'global_commands'}->{$global_command}->[0];
-            $self->set_informative_command_value($element);
-          } else {
-            foreach my $command_element 
(@{$self->{'global_commands'}->{$global_command}}) {
-              if (_in_preamble($command_element)) {
-                $element = $command_element;
-                $self->set_informative_command_value($element);
-              } else {
-                last;
-              }
-            }
-          }
-        }
-      } elsif (defined($self->{'global_commands'}->{$global_command})) {
-        # unique command, first, preamble and last are the same
-        $element = $self->{'global_commands'}->{$global_command};
-        $self->set_informative_command_value($element);
+        print STDERR "SET_global($commands_location) $global_command\n";
       }
+      my $element = Texinfo::Common::set_global_document_command($self,
+               $self->{'global_commands'}, $global_command, 
$commands_location);
       if (not defined($element)) {
         # commands not appearing in the document, this should set the
         # same value, the converter initialization value
-        $self->set_conf($global_command, _command_init($global_command, 
$init_conf));
+        $self->set_conf($global_command,
+                        _command_init($global_command, $init_conf));
       }
     }
   }
@@ -1895,13 +1815,6 @@ I<$element> tree element if given in argument.
 Set the Texinfo configuration option I<$option_string> to I<$value> if
 not set as a converter option.
 
-=item $converter->set_informative_command_value($element)
-
-Set the Texinfo configuration option corresponding to the tree element
-I<$element>.  The command associated to the tree element should be
-a command that sets some information, such as C<@documentlanguage>,
-C<@contents> or C<@footnotestyle> for example.
-
 =item $table_item_tree = $converter->table_item_content_tree($element, 
$contents)
 
 I<$element> should be an C<@item> or C<@itemx> tree element,
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 27362becaa..a8423a8da6 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -614,7 +614,7 @@ sub _convert($$;$)
     } elsif (exists($docbook_misc_commands{$element->{'cmdname'}})) {
       #warn "  is dbk misc command\n";
       if ($docbook_global_commands{$element->{'cmdname'}}) {
-        $self->set_informative_command_value($element);
+        Texinfo::Common::set_informative_command_value($self, $element);
         return '';
       }
       my $docbook_element;
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 51a8bc5efb..ac1aaa6407 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4777,7 +4777,7 @@ sub _convert_informative_command($$$$)
 
   return '' if ($self->in_string());
 
-  $self->set_informative_command_value($command);
+  Texinfo::Common::set_informative_command_value($self, $command);
 
   if ($cmdname eq 'documentlanguage') {
     $self->_translate_names();
@@ -4799,7 +4799,7 @@ sub _convert_contents_command
   return '' if ($self->in_string());
   $cmdname = 'shortcontents' if ($cmdname eq 'summarycontents');
 
-  $self->set_informative_command_value($command);
+  Texinfo::Common::set_informative_command_value($self, $command);
 
   if ($self->get_conf('CONTENTS_OUTPUT_LOCATION') eq 'inline'
       and ($cmdname eq 'contents' or $cmdname eq 'shortcontents')
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 73a38d6746..42452e18dc 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -3021,7 +3021,7 @@ sub _convert($$)
     # use of \usepackage{indentfirst} cannot be reverted.
     } elsif ($informative_commands{$cmdname}) {
 
-      $self->set_informative_command_value($element);
+      Texinfo::Common::set_informative_command_value($self, $element);
 
       if ($cmdname eq 'documentlanguage') {
         my $language = $self->get_conf('documentlanguage');
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 5295014958..2e2d41243e 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -2719,7 +2719,7 @@ sub _convert($$)
     # all the @-commands that have an information for the formatting, like
     # @paragraphindent, @frenchspacing...
     } elsif ($informative_commands{$command}) {
-      $self->set_informative_command_value($element);
+      Texinfo::Common::set_informative_command_value($self, $element);
       return '';
     } else {
       $unknown_command = 1;
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index bfb2c33867..264970422c 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -959,12 +959,6 @@ sub _open_in {
 sub _set_global_informations($)
 {
   my $self = shift;
-
-  #if ($self->{'novalidate'}
-  if ($self->get_conf('novalidate')
-      or $self->global_commands_information()->{'novalidate'}) {
-    $self->{'info'}->{'novalidate'} = 1;
-  }
 }
 
 # parse a texi file
@@ -6084,10 +6078,6 @@ A string, the C<@kbdinputstyle> style.
 A string corresponding to a document language set by C<@documentlanguage>.
 It overrides the document C<@documentlanguage> informations, if present.
 
-=item novalidate
-
-As if C<@novalidate> appeared at the beginning of the document.
-
 =item registrar
 
 Texinfo::Report object reused by the parser to register errors.
@@ -6103,7 +6093,7 @@ Same as values set by C<@set>.
 
 =head2 Parsing Texinfo text
 
-There are three methods that may be called to parse some Texinfo code:
+Different methods may be called to parse some Texinfo code:
 C<parse_texi_line> for a line, C<parse_texi_piece> for a fragment of
 Texinfo, C<parse_texi_text> for a string corresponding to a full document
 and C<parse_texi_file> for a file.
@@ -6269,11 +6259,6 @@ C<input_perl_encoding> string is a corresponding perl 
encoding name.
 
 The name of the main Texinfo input file.
 
-=item novalidate
-
-If set, it means that C<@novalidate> was set in the document or as option
-for the parser, in general from the command-line.
-
 =back
 
 =back
@@ -6396,7 +6381,7 @@ The name of the @-command associated with the index entry.
 =item index_ignore_chars
 
 A hash reference with characters as keys and 1 as value.  Corresponds to
-the characters flaggued as ignored in key sorting in the document by
+the characters flagged as ignored in key sorting in the document by
 setting flags such as I<txiindexbackslashignore>.
 
 =begin comment
@@ -6809,9 +6794,14 @@ Content before nodes and sectioning commands at the 
beginning of C<document_root
 
 =item preamble_before_beginning
 
-This container holds the text appearing before the first content, including
+This container holds everything appearing before the first content, including
 the C<\input texinfo.tex> line and following blank lines.
 
+=item preamble_before_content
+
+This container holds everything appearing before the first formatted content,
+corresponding to the I<Texinfo preamble> in the Texinfo manual.
+
 =item preamble_before_setfilename
 
 This container holds everything that appears before C<@setfilename>.
@@ -6906,7 +6896,7 @@ and
 
   Between entries
 
-will be in I<menu_comment>.
+will be in a I<menu_comment>.
 
 =item macro_name
 
@@ -7262,7 +7252,7 @@ C<@inlinefmtifelse>, and 1 for other commands.
 
 =head1 SEE ALSO
 
-L<Texinfo manual|http://www.gnu.org/s/texinfo/manual/texinfo/>
+L<Texinfo manual|http://www.gnu.org/software/texinfo/manual/texinfo/>.
 
 =head1 AUTHOR
 
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 722107c34e..a5da9f5c58 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -446,7 +446,7 @@ sub set_menus_node_directions($$$$$$)
 
   return undef unless ($nodes_list and scalar(@{$nodes_list}));
 
-  my $check_menu_entries = (!$parser_informations->{'novalidate'}
+  my $check_menu_entries = 
(!$configuration_informations->get_conf('novalidate')
       and $configuration_informations->get_conf('FORMAT_MENU') eq 'menu');
 
   # First go through all the menus and set menu_up, menu_next and menu_prev,
@@ -763,7 +763,7 @@ sub nodes_tree($$$$$)
                = $labels->{$node_direction->{'normalized'}};
             $node->{'structure'}->{'node_'.$direction} = $node_target;
 
-            if (!$parser_informations->{'novalidate'}
+            if (!$configuration_informations->get_conf('novalidate')
                 and !_check_node_same_texinfo_code($node_target,
                                                    $node_direction)) {
               $registrar->line_warn($configuration_informations,
@@ -777,7 +777,7 @@ sub nodes_tree($$$$$)
                 $node->{'line_nr'});
             }
           } else {
-            if ($parser_informations->{'novalidate'}) {
+            if ($configuration_informations->get_conf('novalidate')) {
               $node->{'structure'}->{'node_'.$direction} = { 'extra' => 
$node_direction };
             } else {
               $registrar->line_error($configuration_informations,
@@ -1317,7 +1317,7 @@ sub associate_internal_references($$$$$)
       $node_arg->{'normalized'} = $normalized;
     }
     if (!defined($labels->{$node_arg->{'normalized'}})) {
-      if (!$parser_informations->{'novalidate'}) {
+      if (!$configuration_informations->get_conf('novalidate')) {
         $registrar->line_error($configuration_informations, 
             sprintf(__("\@%s reference to nonexistent node `%s'"),
                 $ref->{'cmdname'}, node_extra_to_texi($node_arg)),
@@ -1326,7 +1326,7 @@ sub associate_internal_references($$$$$)
     } else {
       my $node_target = $labels->{$node_arg->{'normalized'}};
       $ref->{'extra'}->{'label'} = $node_target;
-      if (!$parser_informations->{'novalidate'}
+      if (!$configuration_informations->get_conf('novalidate')
           and !_check_node_same_texinfo_code($node_target, $node_arg)) {
         $registrar->line_warn($configuration_informations,
            sprintf(__("\@%s to `%s', different from %s name `%s'"), 
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm 
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 84684f0087..7e0ce674b6 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -118,8 +118,7 @@ sub parser (;$$)
         set_debug($conf->{$key}) if $conf->{$key};
       } elsif ($key eq 'accept_internalvalue') {
         set_accept_internalvalue();
-      } elsif ($key eq 'novalidate'
-               or $key eq 'registrar') {
+      } elsif ($key eq 'registrar') {
         # no action needed
       } else {
         warn "ignoring parser configuration value \"$key\"\n";
@@ -230,11 +229,6 @@ sub parse_texi_file ($$)
   my $TREE = build_texinfo_tree ();
   get_parser_info ($self);
 
-  if ($self->get_conf('novalidate')
-      or $self->global_commands_information()->{'novalidate'}) {
-    $self->{'info'}->{'novalidate'} = 1;
-  }
-
   _associate_node_menus ($self, $TREE);
 
   my $before_node_section = $TREE->{'contents'}->[0];
@@ -301,12 +295,6 @@ sub parse_texi_piece($$;$$$$)
   get_parser_info($self);
   _associate_node_menus ($self, $tree);
 
-  # TODO remove
-  if ($self->get_conf('novalidate')
-      or $self->global_commands_information()->{'novalidate'}) {
-    $self->{'info'}->{'novalidate'} = 1;
-  }
-
   return $tree;
 }
 
@@ -337,11 +325,6 @@ sub parse_texi_text($$;$$$$)
 
   get_parser_info($self);
 
-  if ($self->get_conf('novalidate')
-      or $self->global_commands_information()->{'novalidate'}) {
-    $self->{'info'}->{'novalidate'} = 1;
-  }
-
   _associate_node_menus ($self, $tree);
 
   my $before_node_section = $tree->{'contents'}->[0];
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 1200df17b2..d572baea2b 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -911,6 +911,11 @@ sub test($$)
 
   Texinfo::Common::set_output_encodings($main_configuration, 
$parser_informations);
 
+  my $global_commands = $parser->global_commands_information();
+  if ($global_commands->{'novalidate'}) {
+    $main_configuration->set_conf('novalidate', 1);
+  }
+
   my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
   my $refs = $parser->internal_references_information();
   Texinfo::Structuring::associate_internal_references($registrar,
@@ -918,8 +923,6 @@ sub test($$)
                                         $parser_informations, $labels, $refs);
   my $floats = $parser->floats_information();
 
-  my $global_commands = $parser->global_commands_information();
-
   my $structure_informations = {};
   my ($sectioning_root, $sections_list)
               = Texinfo::Structuring::sectioning_structure($registrar,
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 440548665e..20b13afd24 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1203,7 +1203,8 @@ while(@input_files) {
   }
 
   # setup a configuration object which defines get_conf and gives the same as
-  # get_conf() in main program
+  # get_conf() in main program.  It is for Structuring/Transformations methods
+  # needing access to the configuration information.
   my $main_configuration = Texinfo::MainConfig::new();
 
   my $parser_informations = $parser->global_informations();
@@ -1211,17 +1212,13 @@ while(@input_files) {
   # encoding and documentlanguage are needed for gdt() in 
regenerate_master_menu
   Texinfo::Common::set_output_encodings($main_configuration, 
$parser_informations);
   my $global_commands = $parser->global_commands_information();
-  # FIXME this is a kind of simplified version of
-  # Texinfo::Convert::Converter::set_global_document_commands
-  # setup a full version in Common.pm
   if (not defined($main_configuration->get_conf('documentlanguage'))) {
-    if (defined($global_commands->{'documentlanguage'})) {
-      my $element = $global_commands->{'documentlanguage'}->[0];
-      my $document_language = $element->{'extra'}->{'text_arg'};
-      if (defined($document_language)) {
-        $main_configuration->set_conf('documentlanguage', $document_language);
-      }
-    }
+    my $element = 
Texinfo::Common::set_global_document_command($main_configuration,
+       $global_commands, 'documentlanguage', 'preamble');
+  }
+  # relevant for many Structuring methods.
+  if ($global_commands->{'novalidate'}) {
+    $main_configuration->set_conf('novalidate', 1);
   }
 
   if (defined(get_conf('MACRO_EXPAND')) and $file_number == 0) {
@@ -1377,6 +1374,11 @@ while(@input_files) {
                             %$file_cmdline_options,
                             %$init_files_options };
 
+  # NOTE nothing set in $main_configuration is passed, which is
+  # clean, the Converters can find that information their way.
+  # It could be possible to pass some information if it allows
+  # for instance to have some consistent information for Structuring
+  # and Converters.
   $converter_options->{'parser'} = $parser;
   $converter_options->{'structuring'} = $structure_informations;
   $converter_options->{'output_format'} = $format;



reply via email to

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