texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (in_multi_expanded):


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (in_multi_expanded): new method accessor for $self->{'multiple_pass'}.
Date: Sun, 23 Jan 2022 14:42:27 -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 89dafeb2a3 * tp/Texinfo/Convert/HTML.pm (in_multi_expanded): new 
method accessor for $self->{'multiple_pass'}.
89dafeb2a3 is described below

commit 89dafeb2a3f2c646f10e7d23bcf1d6dae881adfd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 23 20:42:12 2022 +0100

    * tp/Texinfo/Convert/HTML.pm (in_multi_expanded): new method
    accessor for $self->{'multiple_pass'}.
    
    * tp/Texinfo/Convert/HTML.pm (expanded_format): new method
    accessor for $self->{'expanded_formats_hash'}.
    
    * tp/Texinfo/Convert/HTML.pm (_convert_raw_command): hardcode
    'html' as the format not protected and not warned if expanded.
    
    * tp/Texinfo/Convert/HTML.pm (_convert_printindex_command):
    call convert_tree_new_formatting_context() in case of multiple
    formatting of index entry.
    
    * tp/Texinfo/Convert/HTML.pm (converter_initialize, _convert): remove
    $self->{'commands_args'} use directly %default_commands_args.
---
 ChangeLog                  | 18 +++++++++
 tp/TODO                    | 19 ++-------
 tp/Texinfo/Convert/HTML.pm | 99 +++++++++++++++++++++++-----------------------
 3 files changed, 70 insertions(+), 66 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3e1876992a..f58683baad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2022-01-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (in_multi_expanded): new method
+       accessor for $self->{'multiple_pass'}.
+
+       * tp/Texinfo/Convert/HTML.pm (expanded_format): new method
+       accessor for $self->{'expanded_formats_hash'}.
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_raw_command): hardcode
+       'html' as the format not protected and not warned if expanded.
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_printindex_command):
+       call convert_tree_new_formatting_context() in case of multiple
+       formatting of index entry.
+
+       * tp/Texinfo/Convert/HTML.pm (converter_initialize, _convert): remove
+       $self->{'commands_args'} use directly %default_commands_args.
+
 2022-01-23  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Config.pm (texinfo_register_file_id_setting_function)
diff --git a/tp/TODO b/tp/TODO
index cab87c9aee..b34062aa2b 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -24,27 +24,17 @@ Issues
 ------
 
 Some internal state used in conversion:
- _convert_anchor_command:
-  $self->{'multiple_pass'}
  _convert_footnote_command:
   $self->{'current_filename'}
-  $self->{'multiple_pass'}->[-1]
  _convert_explained_command (actually internal to the function)
   $self->{'explained_commands'}
   $self->{'element_explanation_contents'}
- _convert_raw_command
-  $self->{'output_format'}
- _convert_inline_command
-  $self->{'expanded_formats_hash'}
  _convert_itemize_command
   $self->{'css_map'}
  _get_copiable_anchor (called by 2 convert functions)
   $self->{'paragraph_symbol'}
- _convert_index_command
-  @{$self->{'multiple_pass'}}
  _convert_printindex_command
   $self->{'index_entries_by_letter'}
-  $self->{'ignore_notice'}++
  _convert_special_element_type
   $self->{'counter_in_file'}->{$element->{'structure'}->{'unit_filename'}} == 1
 
@@ -103,12 +93,6 @@ init/tex4ht.pm
 init/tex4ht.pm
   $self->{'css_import_lines'}
 
-t/init/command_translation_modified.init
-  $commands_translation{'normal'}->{'error'} 
-
-t/init/cvs.init
-  $texinfo_code_types->{'menu_comment'} = 1;
-
 
 To document:
 -----------
@@ -202,7 +186,10 @@ $self->table_item_content_tree() (Converter)
 $self->comma_index_subentries_tree() (Converter)
 $self->paragraph_number()
 $self->top_block_command()
+$self->expanded_format($format)
+$self->in_multi_expanded()
 $self->html_get_css_elements_classes($filename);
+$self->substitute_html_non_breaking_space(
 
 Profiling
 =========
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 145f03ef4c..70f50718cc 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -42,9 +42,6 @@
 # done in that case, without any HTML element such that the result
 # can be in an attribute or in a comment.
 #
-# FIXME: there are already cases with side effects, with the
-# variables $html_menu_entry_index, $foot_lines.
-# 
 # Original author: Patrice Dumas <pertusus@free.fr>
 
 package Texinfo::Convert::HTML;
@@ -208,7 +205,7 @@ sub html_attribute_class($$;$)
   return "<$element class=\"$class_str\"$style";
 }
 
-# those rules cannot be collected during document output since they
+# for rules that cannot be collected during document output since they
 # are not associated with a class attribute element setting
 my %css_rules_not_collected = (
 );
@@ -461,6 +458,15 @@ sub in_raw($)
   return $self->{'document_context'}->[-1]->{'raw'};
 }
 
+sub in_multi_expanded($)
+{
+  my $self = shift;
+  if (scalar(@{$self->{'multiple_pass'}})) {
+    return $self->{'multiple_pass'}->[-1];
+  }
+  return undef;
+}
+
 sub paragraph_number($)
 {
   my $self = shift;
@@ -508,6 +514,14 @@ sub in_align($)
   }
 }
 
+sub expanded_format($$)
+{
+  my $self = shift;
+  my $format = shift;
+
+  return $self->{'expanded_formats_hash'}->{$format};
+}
+
 # the main data structure of the element target API is a hash reference, called
 # the target information.
 # The 'target' and 'filename' keys should be set for every type of element,
@@ -1270,7 +1284,7 @@ sub get_file_information($$;$)
 
 # This function should be used in formatting functions when some
 # Texinfo tree need to be converted.
-sub convert_tree_new_formatting_context($$;$$)
+sub convert_tree_new_formatting_context($$;$$$)
 {
   my $self = shift;
   my $tree = shift;
@@ -1824,7 +1838,7 @@ my %default_code_types = (
  '_code' => 1,
 );
 
-# default specification of arguments formatting
+# specification of arguments formatting
 my %default_commands_args = (
   'email' => [['monospace', 'monospacestring'], ['normal']],
   'anchor' => [['monospacestring']],
@@ -2428,7 +2442,7 @@ sub _convert_anchor_command($$$$)
   my $args = shift;
 
   my $id = $self->command_id($command);
-  if (defined($id) and $id ne '' and !@{$self->{'multiple_pass'}}
+  if (defined($id) and $id ne '' and !$self->in_multi_expanded()
       and !$self->in_string()) {
     return &{$self->formatting_function('format_separate_anchor')}($self,
                                                            $id, 'anchor');
@@ -2499,9 +2513,10 @@ sub _convert_footnote_command($$$$)
   chomp ($footnote_text);
   $footnote_text .= "\n";
 
-  if (@{$self->{'multiple_pass'}}) {
-    $footid = 
$target_prefix.$self->{'multiple_pass'}->[-1].'_'.$footid.'_'.$foot_num;
-    $docid = 
$target_prefix.$self->{'multiple_pass'}->[-1].'_'.$docid.'_'.$foot_num;
+  my $multi_expanded_region = $self->in_multi_expanded();
+  if (defined($multi_expanded_region)) {
+    $footid = $target_prefix.$multi_expanded_region.'_'.$footid.'_'.$foot_num;
+    $docid = $target_prefix.$multi_expanded_region.'_'.$docid.'_'.$foot_num;
   } else {
     if (!defined($footnote_id_numbers{$footid})) {
       $footnote_id_numbers{$footid} = $foot_num;
@@ -3463,7 +3478,7 @@ sub _convert_raw_command($$$$)
   my $command = shift;
   my $content = shift;
 
-  if ($cmdname eq $self->{'output_format'}) {
+  if ($cmdname eq 'html') {
     return $content;
   }
   $self->_noticed_line_warn(sprintf(__("raw format %s is not converted"),
@@ -3493,9 +3508,9 @@ sub _convert_inline_command($$$$)
   my $arg_index = undef;
   if ($inline_format_commands{$cmdname}) {
     if ($cmdname eq 'inlinefmtifelse' 
-        and ! $self->{'expanded_formats_hash'}->{$format}) {
+        and ! $self->expanded_format($format)) {
       $arg_index = 1;
-    } elsif ($self->{'expanded_formats_hash'}->{$format}) {
+    } elsif ($self->expanded_format($format)) {
       $arg_index = 0;
     }
   } elsif (defined($command->{'extra'}->{'expand_index'})) {
@@ -4568,7 +4583,7 @@ sub _convert_index_command($$$$)
 
   my $index_id = $self->command_id($command);
   if (defined($index_id) and $index_id ne ''
-      and !@{$self->{'multiple_pass'}}
+      and !$self->in_multi_expanded()
       and !$self->in_string()) {
     my $result = &{$self->formatting_function('format_separate_anchor')}($self,
                                                    $index_id, 
'index-entry-id');
@@ -4687,30 +4702,24 @@ sub _convert_printindex_command($$$$)
       if (!$formatted_index_entries{$index_entry_ref}) {
         $formatted_index_entries{$index_entry_ref} = 1;
       } else {
-        $already_formatted = 1;
-        $self->{'ignore_notice'}++;
+        $formatted_index_entries{$index_entry_ref}++;
       }
 
-      my $entry;
       my $subentries_tree = 
$self->comma_index_subentries_tree($index_entry_ref);
-      if ($index_entry_ref->{'in_code'}) {
-        $entry = $self->convert_tree({'type' => '_code',
-                                     'contents' => 
$index_entry_ref->{'content'}},
-                             "index $index_name l $letter index entry 
$entry_nr");
-        $entry .= $self->convert_tree({'type' => '_code',
-                                     'contents' => 
$subentries_tree->{'contents'}},
-                        "index $index_name l $letter index sub entries 
$entry_nr")
-           if (defined($subentries_tree));
+      my @entry_contents = @{$index_entry_ref->{'content'}};
+      push @entry_contents, @{$subentries_tree->{'contents'}}
+        if (defined($subentries_tree));
+      my $entry_tree = {'contents' => \@entry_contents};
+      $entry_tree->{'type'} = '_code' if ($index_entry_ref->{'in_code'});
+
+      my $entry;
+      if ($formatted_index_entries{$index_entry_ref} > 1) {
+        $entry = $self->convert_tree_new_formatting_context($entry_tree,
+                       "index $index_name l $letter index entry $entry_nr",
+                   "index formatted 
$formatted_index_entries{$index_entry_ref}")
       } else {
-        $entry = $self->convert_tree({'contents' => 
$index_entry_ref->{'content'}},
-                              "index $index_name l $letter index entry 
$entry_nr");
-        $entry .= $self->convert_tree(
-                                  {'contents'  => 
$subentries_tree->{'contents'}},
-                        "index $index_name l $letter index sub entries 
$entry_nr")
-           if (defined($subentries_tree));
-      }
-      if ($already_formatted) {
-        $self->{'ignore_notice'}--;
+        $entry = $self->convert_tree($entry_tree,
+                            "index $index_name l $letter index entry 
$entry_nr");
       }
 
       next if ($entry !~ /\S/);
@@ -4794,9 +4803,9 @@ sub _contents_inline_element($$$)
     } else {
       # happens when called as convert() and not output()
       #cluck "$cmdname special element not defined";
-      $heading 
-        = 
$self->convert_tree($self->get_conf('SPECIAL_ELEMENTS_HEADING')->{$special_element_type},
-                              "convert $cmdname special heading");
+      $heading = 
$self->convert_tree($self->get_conf('SPECIAL_ELEMENTS_HEADING')
+                                                       
->{$special_element_type},
+                                     "convert $cmdname special heading");
     }
     $result .= ">\n";
     $result .= &{$self->formatting_function('format_heading_text')}($self,
@@ -5414,7 +5423,7 @@ sub _convert_def_line_type($$$$)
 
   my $index_label = '';
   my $index_id = $self->command_id($command);
-  if (defined($index_id) and $index_id ne '' and !@{$self->{'multiple_pass'}}) 
{
+  if (defined($index_id) and $index_id ne '' and !$self->in_multi_expanded()) {
     $index_label = " id=\"$index_id\"";
   }
   my $arguments
@@ -6360,9 +6369,6 @@ sub _load_htmlxref_files {
 #  htmlxref
 #  check_htmlxref_already_warned
 #  
-#  commands_args (though it does not seems to be dynamic.
-#                 FIXME: always point to default?)
-#
 #    API exists
 #  file_id_setting
 #  commands_conversion
@@ -6380,7 +6386,6 @@ sub _load_htmlxref_files {
 #    API exists
 #  pending_closes
 #
-#  multiple_pass
 #  ignore_notice
 #
 #    API exists
@@ -6659,12 +6664,6 @@ sub converter_initialize($)
     }
   }
 
-  foreach my $command (keys %{$self->{'commands_conversion'}}) {
-    if (exists($default_commands_args{$command})) {
-      $self->{'commands_args'}->{$command} = $default_commands_args{$command};
-    }
-  }
-
   my $customized_file_id_setting_references
     = Texinfo::Config::GNUT_get_file_id_setting_references();
   # first check the validity of the names
@@ -9496,8 +9495,8 @@ sub _convert($$;$)
         $args_formatted = [];
         if ($element->{'args'}) {
           my @args_specification;
-          @args_specification = @{$self->{'commands_args'}->{$command_name}}
-            if (defined($self->{'commands_args'}->{$command_name}));
+          @args_specification = @{$default_commands_args{$command_name}}
+            if (defined($default_commands_args{$command_name}));
           my $arg_idx = 0;
           foreach my $arg (@{$element->{'args'}}) {
             my $arg_spec = shift @args_specification;



reply via email to

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