texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Thu, 18 Jan 2024 18:44:53 -0500 (EST)

branch: master
commit 5ed6ae9da1d602ddab6307548515d5160d12eb32
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jan 19 00:39:27 2024 +0100

    * tp/Texinfo/Convert/Converter.pm (set_document),
    tp/Texinfo/Convert/DocBook.pm (_index_entry),
    tp/Texinfo/Convert/HTML.pm (_convert_printindex_command)
    (_sort_index_entries, _prepare_index_entries_targets)
    (output_internal_links), tp/Texinfo/Convert/IXIN.pm,
    tp/Texinfo/Convert/LaTeX.pm (_prepare_indices, _index_entry),
    tp/Texinfo/Convert/Plaintext.pm (process_printindex),
    tp/Texinfo/Convert/TexinfoMarkup.pm (_index_entry, _convert),
    tp/init/chm.pm): do not set 'indices_information', instead use
    document indices_information to get indices information.
---
 ChangeLog                           | 13 ++++++++++
 doc/texi2any_api.texi               | 51 ++++++++++++++++++++-----------------
 tp/Texinfo/Convert/Converter.pm     |  7 ++---
 tp/Texinfo/Convert/DocBook.pm       |  8 +++++-
 tp/Texinfo/Convert/HTML.pm          | 30 +++++++++++++++++-----
 tp/Texinfo/Convert/IXIN.pm          |  3 ++-
 tp/Texinfo/Convert/LaTeX.pm         | 17 ++++++++++---
 tp/Texinfo/Convert/Plaintext.pm     |  8 ++++--
 tp/Texinfo/Convert/TexinfoMarkup.pm | 14 ++++++++--
 tp/init/chm.pm                      | 16 +++++++-----
 10 files changed, 115 insertions(+), 52 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b236ca45e9..c762c34e0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,19 @@
        * tp/Texinfo/Common.pm (debug_print_tree): Also print 'unit_contents'
        keys to allow printing an "output unit".
 
+2024-01-18  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Converter.pm (set_document),
+       tp/Texinfo/Convert/DocBook.pm (_index_entry),
+       tp/Texinfo/Convert/HTML.pm (_convert_printindex_command)
+       (_sort_index_entries, _prepare_index_entries_targets)
+       (output_internal_links), tp/Texinfo/Convert/IXIN.pm,
+       tp/Texinfo/Convert/LaTeX.pm (_prepare_indices, _index_entry),
+       tp/Texinfo/Convert/Plaintext.pm (process_printindex),
+       tp/Texinfo/Convert/TexinfoMarkup.pm (_index_entry, _convert),
+       tp/init/chm.pm): do not set 'indices_information', instead use
+       document indices_information to get indices information.
+
 2024-01-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/Converter.pm (set_document)
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 6e1c77677e..29ec355092 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -1765,6 +1765,34 @@ Destination directory for the output files.  It is 
common to use that string in
 or file paths with functions requiring binary strings.  In that case the
 character string needs to be encoded.  @xref{Encoding File Path Strings}.
 
+@item document
+The @code{Texinfo::Document} parsed Texinfo document being converted.
+Some information is available from the document using function accessors:
+
+@table @code
+@item floats_information
+Information on floats.
+@xref{Texinfo::Document $float_types = floats_information($document),,
+Texinfo::Document::floats_information,texi2any_internals}.
+
+@item global_commands_information
+Global commands information.
+@xref{Texinfo::Document $commands = global_commands_information($document),,
+Texinfo::Document::global_commands_information,texi2any_internals}.
+
+@item global_information
+Diverse information.
+@xref{Texinfo@asis{::}Document $info = global_information($document),,
+Texinfo@asis{::}Document@asis{::}global_information,texi2any_internals}.
+
+@item indices_information
+Information about defined indices, merged indices and index entries.
+@xref{Texinfo@asis{::}Document $indices_information = 
$document->indices_information(),,Texinfo@asis{::}Document@asis{::}indices_information,texi2any_internals}.
+
+@item sections_list
+List of the sectioning commands in the document.
+@end table
+
 @item document_name
 Base name of the document.  It is common to use that string in in directory or
 file paths with functions requiring binary strings.  In that case the character
@@ -1782,16 +1810,6 @@ hash reference with format names as key and a true value 
as value if
 the format is expanded, according to command-line and init file
 information.
 
-@item floats
-Information on floats. Gathered from the Texinfo parsing result.
-@xref{Texinfo::Document $float_types = floats_information($document),,
-Texinfo::Document::floats_information,texi2any_internals}.
-
-@item global_commands
-Global commands information.  Gathered from the Texinfo parsing result.
-@xref{Texinfo::Document $commands = global_commands_information($document),,
-Texinfo::Document::global_commands_information,texi2any_internals}.
-
 @item index_entries
 Information on indices taking into account merged indices.
 @xref{Texinfo::Structuring $merged_entries = 
merge_indices($index_names),,Texinfo::Structuring::merge_indices, 
texi2any_internals}.
@@ -1799,10 +1817,6 @@ Information on indices taking into account merged 
indices.
 @item index_entries_by_letter
 Index entries sorted by letter. @xref{Texinfo::Structuring 
($index_entries_sorted@comma{} $index_entries_sort_strings) = 
sort_indices($registrar@comma{} $configuration_information@comma{} 
$merged_index_entries@comma{} 
$sort_by_letter),,Texinfo::Structuring::sort_indices,texi2any_internals}.
 
-@item indices_information
-Information about defined indices, merged indices and index entries.
-@xref{Texinfo@asis{::}Document $indices_information = 
$document->indices_information(),,Texinfo@asis{::}Document@asis{::}indices_information,texi2any_internals}.
-
 @item jslicenses
 An hash reference with  categories of javascript used in the document
 as keys. The corresponding values are also hashes with file names
@@ -1814,12 +1828,6 @@ information on each of the file licences, with content
 @item file name or source of file
 @end enumerate
 
-@item labels
-Association of identifiers to label elements. Gathered from the Texinfo
-parsing result.
-@xref{Texinfo::Parser $labels_information@comma{} $targets_list@comma{} 
$nodes_list = labels_information($parser),,
-Texinfo::Parser::labels_information,texi2any_internals}.
-
 @item line_break_element
 HTML line break element, based on @samp{<br>}, also taking into account
 @code{USE_XML_SYNTAX} customization variable value.
@@ -1851,9 +1859,6 @@ all the title-related commands, including @code{@@top} and
 a Texinfo tree corresponding to the simpletitle, and 
@code{simpletitle_command_name}
 is the @@-command name used for the simpletitle, without the leading @@.
 
-@item sections_list
-List of the sectioning commands in the document.
-
 @item title_titlepage
 The formatted title, possibly based on @code{@@titlepage}, or on
 @code{simpletitle_tree} and similar information, depending on @code{SHOW_TITLE}
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index dc55f5670f..87e4620a0a 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -265,10 +265,7 @@ sub set_document($$)
   }
 
   $converter->{'document'} = $document;
-  if (defined($document)) {
-    $converter->{'indices_information'}
-           = $document->indices_information();
-  }
+
   Texinfo::Common::set_output_encodings($converter, $document);
 
   $converter->{'convert_text_options'}
@@ -2122,7 +2119,7 @@ are described in the Texinfo manual.
 Those customization options, when appropriate, override the document content.
 B<TODO what about the other options (all are used in converters>
 B<TODO document this associated information
-('indices_information' ..., most available
+(..., most available
 in HTML converter, either through $converter-E<gt>get_info('document') or 
label_command())>
 
 The C<converter> function returns a converter object (a blessed hash
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 75b11577c8..8fe5068c56 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -616,9 +616,15 @@ sub _index_entry($$)
   my $self = shift;
   my $element = shift;
   if ($element->{'extra'} and $element->{'extra'}->{'index_entry'}) {
+
+    my $indices_information;
+    if ($self->{'document'}) {
+      $indices_information = $self->{'document'}->indices_information();
+    }
+
     my ($index_entry, $index_info)
      = 
Texinfo::Common::lookup_index_entry($element->{'extra'}->{'index_entry'},
-                                           $self->{'indices_information'});
+                                           $indices_information);
     # FIXME DocBook 5 role->type
     my $result = "<indexterm role=\"$index_entry->{'index_name'}\">";
 
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index d3cd2cbc93..63cf4dfcd4 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2305,8 +2305,7 @@ my %available_converter_info;
 foreach my $converter_info ('copying_comment', 'current_filename',
    'destination_directory', 'document', 'document_name',
    'documentdescription_string', 'expanded_formats',
-   'index_entries', 'index_entries_by_letter', 'indices_information',
-   'jslicenses',
+   'index_entries', 'index_entries_by_letter', 'jslicenses',
    'line_break_element', 'non_breaking_space', 'paragraph_symbol',
    'simpletitle_command_name', 'simpletitle_tree',
    'title_string', 'title_tree', 'title_titlepage') {
@@ -6217,6 +6216,12 @@ sub _convert_printindex_command($$$$)
     return '';
   }
 
+  my $document = $self->get_info('document');
+  my $indices_information;
+  if ($document) {
+    $indices_information = $document->indices_information();
+  }
+
   #foreach my $letter_entry (@{$index_entries_by_letter->{$index_name}}) {
   #  print STDERR "IIIIIII $letter_entry->{'letter'}\n";
   #  foreach my $index_entry (@{$letter_entry->{'entries'}}) {
@@ -6296,7 +6301,6 @@ sub _convert_printindex_command($$$$)
           = Texinfo::Common::index_content_element($main_entry_element);
 
       my $in_code = 0;
-      my $indices_information = $self->get_info('indices_information');
       $in_code = 1
        if 
($indices_information->{$index_entry_ref->{'index_name'}}->{'in_code'});
       my $entry_ref_tree = {'contents' => [$entry_content_element]};
@@ -10268,7 +10272,11 @@ sub _sort_index_entries($)
 {
   my $self = shift;
 
-  my $indices_information = $self->{'indices_information'};
+  my $indices_information;
+  if ($self->{'document'}) {
+    $indices_information = $self->{'document'}->indices_information();
+  }
+
   if ($indices_information) {
 
     my $merged_index_entries
@@ -10294,7 +10302,11 @@ sub _prepare_index_entries_targets($)
 {
   my $self = shift;
 
-  my $indices_information = $self->{'indices_information'};
+  my $indices_information;
+  if ($self->{'document'}) {
+    $indices_information = $self->{'document'}->indices_information();
+  }
+
   if ($indices_information) {
     my $no_unidecode;
     $no_unidecode = 1 if (defined($self->get_conf('USE_UNIDECODE'))
@@ -11988,6 +12000,11 @@ sub output_internal_links($)
   }
   my $index_entries_by_letter = $self->get_info('index_entries_by_letter');
   if ($index_entries_by_letter) {
+    my $indices_information;
+    if ($self->{'document'}) {
+      $indices_information = $self->{'document'}->indices_information();
+    }
+
     foreach my $index_name (sort(keys (%{$index_entries_by_letter}))) {
       foreach my $letter_entry (@{$index_entries_by_letter->{$index_name}}) {
         foreach my $index_entry (@{$letter_entry->{'entries'}}) {
@@ -12000,8 +12017,7 @@ sub output_internal_links($)
           $href = $self->command_href($main_entry_element, '');
           # Obtain term by converting to text
           my $in_code
-            = $self->{'indices_information'}->{$index_entry->{'index_name'}}
-                                                                 ->{'in_code'};
+            = 
$indices_information->{$index_entry->{'index_name'}}->{'in_code'};
           if ($in_code) {
             Texinfo::Convert::Text::set_options_code(
                                           $self->{'convert_text_options'});
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 27947700d6..a7936e71b3 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -384,11 +384,13 @@ sub output_ixin($$)
   my $floats;
   my $sections_list;
   my $identifiers_target;
+  my $indices_information;
   if ($self->->{'document'}) {
     $document_info = $self->{'document'}->global_information();
     $floats = $self->{'document'}->floats_information();
     $sections_list = $self->{'document'}->sections_list();
     $identifiers_target = $self->{'document'}->labels_information();
+    $indices_information = $self->{'document'}->indices_information();
   }
 
   if ($document_info and $document_info->{'dircategory_direntry'}) {
@@ -704,7 +706,6 @@ sub output_ixin($$)
 
   my %dts_information;
 
-  my $indices_information = $self->{'indices_information'};
   if ($indices_information) {
     my $merged_index_entries
         = Texinfo::Indices::merge_indices($indices_information);
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 85950880ba..5522e8be6d 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -948,12 +948,16 @@ sub _prepare_indices($)
 {
   my $self = shift;
 
-  my $index_names = $self->{'indices_information'};
-  if ($index_names) {
+  my $indices_information;
+  if ($self->{'document'}) {
+    $indices_information = $self->{'document'}->indices_information();
+  }
+
+  if ($indices_information) {
     $self->{'index_formatting_text_options'}
       = Texinfo::Indices::setup_index_entry_keys_formatting($self);
     my $merged_index_entries
-        = Texinfo::Indices::merge_indices($index_names);
+        = Texinfo::Indices::merge_indices($indices_information);
     # select non empty indices
     if ($merged_index_entries) {
       $self->{'index_entries'} = {};
@@ -2456,9 +2460,14 @@ sub _index_entry($$)
   my $self = shift;
   my $element = shift;
   if ($element->{'extra'} and $element->{'extra'}->{'index_entry'}) {
+    my $indices_information;
+    if ($self->{'document'}) {
+      $indices_information = $self->{'document'}->indices_information();
+    }
+
     my ($entry, $index_info)
      = 
Texinfo::Common::lookup_index_entry($element->{'extra'}->{'index_entry'},
-                                           $self->{'indices_information'});
+                                           $indices_information);
     my $entry_index_name = $entry->{'index_name'};
     my $index_name = $entry_index_name;
     if ($index_info->{'merged_in'}) {
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index fa8b9ec6cf..5f839aa847 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1492,8 +1492,12 @@ sub process_printindex($$;$)
     return '';
   }
 
+  my $indices_information;
+  if ($self->{'document'}) {
+    $indices_information = $self->{'document'}->indices_information();
+  }
+
   # this is not redone for each index, only once
-  my $indices_information = $self->{'indices_information'};
   if (!defined($self->{'index_entries'}) and $indices_information) {
 
     my $merged_index_entries
@@ -1597,7 +1601,7 @@ sub process_printindex($$;$)
     my $entry_tree = {'contents' => [$entry_content_element]};
     my $subentries_tree
        = $self->comma_index_subentries_tree($main_entry_element);
-    if ($self->{'indices_information'}->{$entry_index_name}->{'in_code'}) {
+    if ($indices_information->{$entry_index_name}->{'in_code'}) {
       $entry_tree->{'type'} = '_code';
       $subentries_tree->{'type'} = '_code'
         if (defined($subentries_tree));
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm 
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index b0a0ffd730..55ded79ad7 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -385,9 +385,14 @@ sub _index_entry($$)
   my $self = shift;
   my $element = shift;
   if ($element->{'extra'} and $element->{'extra'}->{'index_entry'}) {
+    my $indices_information;
+    if ($self->{'document'}) {
+      $indices_information = $self->{'document'}->indices_information();
+    }
+
     my ($index_entry, $index_info)
      = 
Texinfo::Common::lookup_index_entry($element->{'extra'}->{'index_entry'},
-                                           $self->{'indices_information'});
+                                           $indices_information);
     my $attribute = [['index', $index_entry->{'index_name'}]];
     push @$attribute, ['number', $index_entry->{'entry_number'}]
         if (defined($index_entry->{'entry_number'}));
@@ -772,9 +777,14 @@ sub _convert($$;$)
         # out of block commands @item, @itemx in enumerate or multitable...
     } elsif ($element->{'type'} and $element->{'type'} eq 'index_entry_command'
              and $element->{'extra'} and $element->{'extra'}->{'index_entry'}) 
{
+      my $indices_information;
+      if ($self->{'document'}) {
+        $indices_information = $self->{'document'}->indices_information();
+      }
+
       my ($index_entry, $index_info)
         = 
Texinfo::Common::lookup_index_entry($element->{'extra'}->{'index_entry'},
-                                              $self->{'indices_information'});
+                                              $indices_information);
       my $format_element;
       my $attribute = [];
       if (exists $line_commands{$element->{'cmdname'}}) {
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index f1f175c0f9..1cabfeea51 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -239,10 +239,18 @@ sub chm_init($)
   }
   print $hhk_fh "</OBJECT>\n";
 
+  my $document = $self->get_info('document');
+  my $indices_information;
+  my $sections_list;
+  if ($document) {
+    $indices_information = $document->indices_information();
+    $sections_list = $document->sections_list();
+  }
+
   my ($index_entries, $index_entries_sort_strings)
        = Texinfo::Indices::sort_indices_by_index(undef, $self,
                              $self->get_info('index_entries'),
-                             $self->get_info('indices_information'));
+                             $indices_information);
   if ($index_entries) {
     foreach my $index_name (sort(keys(%$index_entries))) {
       foreach my $index_entry_ref (@{$index_entries->{$index_name}}) {
@@ -255,7 +263,6 @@ sub chm_init($)
         my $origin_href = $self->command_href($main_entry_element, '');
         my $entry_content_element
               = Texinfo::Common::index_content_element($main_entry_element);
-        my $indices_information = $self->get_info('indices_information');
         my $in_code = 0;
         $in_code = 1
           if 
($indices_information->{$index_entry_ref->{'index_name'}}->{'in_code'});
@@ -314,11 +321,6 @@ sub chm_init($)
   }
   print $hhc_fh "</OBJECT>\n";
 
-  my $sections_list;
-  if ($self->{'document'}) {
-    $sections_list = $self->{'document'}->sections_list();
-  }
-
   if ($sections_list) {
     my $section_root = $sections_list->[0]
                                          ->{'extra'}->{'sectioning_root'};



reply via email to

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