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 (command_name_specia


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (command_name_special_element_information, command_contents_href) (_contents_inline_element, _html_get_tree_root_element): add command_name_special_element_information() to get information on a special element associated with an @-command name.
Date: Tue, 25 Jan 2022 16:31: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 235d30a16f * tp/Texinfo/Convert/HTML.pm 
(command_name_special_element_information, command_contents_href) 
(_contents_inline_element, _html_get_tree_root_element): add 
command_name_special_element_information() to get information on a special 
element associated with an @-command name.
235d30a16f is described below

commit 235d30a16f41e8c01b16951ace671e263a323362
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jan 25 22:31:15 2022 +0100

    * tp/Texinfo/Convert/HTML.pm
    (command_name_special_element_information, command_contents_href)
    (_contents_inline_element, _html_get_tree_root_element): add
    command_name_special_element_information() to get information
    on a special element associated with an @-command name.
---
 ChangeLog                  |  8 +++++
 tp/TODO                    |  6 ++--
 tp/Texinfo/Convert/HTML.pm | 81 ++++++++++++++++++++++++++++------------------
 3 files changed, 59 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ca6b2a8c0a..7563ba043c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-01-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm
+       (command_name_special_element_information, command_contents_href)
+       (_contents_inline_element, _html_get_tree_root_element): add
+       command_name_special_element_information() to get information
+       on a special element associated with an @-command name.
+
 2022-01-25  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (format_footnotes_segment):
diff --git a/tp/TODO b/tp/TODO
index 9ed9c4a2b7..403d3b8c3d 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -16,7 +16,6 @@ Before next release
 Bugs
 ====
 
-
 HTML API
 ========
 
@@ -35,8 +34,6 @@ Some private variables/private state used in conversion
   $self->{'element_explanation_contents'}
  _convert_footnote_command:
   $foot_num, %footnote_id_numbers
- _contents_inline_element
-  %contents_command_element_type
  _convert_printindex_command
   %formatted_index_entries
  _convert_menu_command
@@ -88,7 +85,8 @@ used in _contents_inline_element
 from_element_direction
 command_target command_filename command_string command_id command_href
 command_contents_href command_contents_target
-special_element (argument: a $special_element_direction?)
+special_direction_element
+command_name_special_element_information
 command_root_element_command label_command
 footnote_location_target footnote_location_href
 
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index cc2e648e46..a580319b27 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -840,15 +840,11 @@ sub command_contents_href($$$;$)
   $source_filename = $self->{'current_filename'}
     if (not defined($source_filename));
 
-  my $special_element_type
-    = $contents_command_element_type{$contents_or_shortcontents};
-  my $special_element_direction
-       = 
$self->get_conf('SPECIAL_ELEMENTS_DIRECTIONS')->{$special_element_type};
+  my ($special_element_type, $target_element, $class_base,
+    $special_element_direction)
+     = 
$self->command_name_special_element_information($contents_or_shortcontents);
   my $target
     = $self->command_contents_target($command, $contents_or_shortcontents);
-
-  my $target_element
-    = $self->special_direction_element($special_element_direction);
   my $target_filename;
   # !defined happens when called as convert() and not output()
   if (defined($target_element)) {
@@ -992,7 +988,7 @@ sub command_text($$;$)
         my $special_element_type = 
$command->{'extra'}->{'special_element_type'};
         $tree = 
$self->get_conf('SPECIAL_ELEMENTS_HEADING')->{$special_element_type};
         $explanation = "command_text $special_element_type";
-      } elsif ($command->{'cmdname'} and ($command->{'cmdname'} eq 'node' 
+      } elsif ($command->{'cmdname'} and ($command->{'cmdname'} eq 'node'
                                           or $command->{'cmdname'} eq 
'anchor')) {
         $tree = {'type' => '_code',
                  'contents' => $command->{'extra'}->{'node_content'}};
@@ -1018,28 +1014,28 @@ sub command_text($$;$)
                              {'number'
                                 => {'text' => 
$command->{'structure'}->{'section_number'}},
                               'section_title'
-                                => {'contents' 
+                                => {'contents'
                                     => 
$command->{'args'}->[0]->{'contents'}}});
           } else {
             $tree = $self->gdt('{number} {section_title}',
                              {'number'
                                 => {'text' => 
$command->{'structure'}->{'section_number'}},
                               'section_title'
-                                => {'contents' 
+                                => {'contents'
                                     => 
$command->{'args'}->[0]->{'contents'}}});
           }
         } else {
           $tree = {'contents' => [@{$command->{'args'}->[0]->{'contents'}}]};
         }
 
-        $target->{'tree_nonumber'} 
+        $target->{'tree_nonumber'}
           = {'contents' => $command->{'args'}->[0]->{'contents'}};
       }
       $target->{'tree'} = $tree;
     } else {
       $tree = $target->{'tree'};
     }
-    return $target->{'tree_nonumber'} if ($type eq 'tree_nonumber' 
+    return $target->{'tree_nonumber'} if ($type eq 'tree_nonumber'
                                           and $target->{'tree_nonumber'});
     return $tree if ($type eq 'tree' or $type eq 'tree_nonumber');
     
@@ -1051,7 +1047,7 @@ sub command_text($$;$)
     }
     
     if ($type =~ /^(.*)_nonumber$/) {
-      $tree = $target->{'tree_nonumber'} 
+      $tree = $target->{'tree_nonumber'}
         if (defined($target->{'tree_nonumber'}));
     }
     $self->{'ignore_notice'}++;
@@ -1082,6 +1078,28 @@ sub special_direction_element($$)
   return $self->{'special_elements_directions'}->{$direction};
 }
 
+sub command_name_special_element_information($$)
+{
+  my $self = shift;
+  my $cmdname = shift;
+
+  my $special_element_type;
+  if (exists($contents_command_element_type{$cmdname})) {
+    $special_element_type = $contents_command_element_type{$cmdname};
+  } elsif ($cmdname eq 'footnote') {
+    $special_element_type = 'footnotes';
+  } else {
+    return (undef, undef, undef, undef);
+  }
+  my $special_element_direction
+    = $self->get_conf('SPECIAL_ELEMENTS_DIRECTIONS')->{$special_element_type};
+  my $special_element
+    = $self->special_direction_element($special_element_direction);
+  my $class_base = 
$self->get_conf('SPECIAL_ELEMENTS_CLASS')->{$special_element_type};
+  return ($special_element_type, $special_element, $class_base,
+          $special_element_direction);
+}
+
 sub global_element($$)
 {
   my $self = shift;
@@ -2093,7 +2111,7 @@ $default_commands_conversion{'page'} = undef;
 $default_commands_conversion{'need'} = undef;
 $default_commands_conversion{'vskip'} = undef;
 
-foreach my $ignored_brace_commands ('caption', 'shortcaption', 
+foreach my $ignored_brace_commands ('caption', 'shortcaption',
   'hyphenation', 'sortas') {
   $default_commands_conversion{$ignored_brace_commands} = undef;
 }
@@ -4972,14 +4990,11 @@ sub _contents_inline_element($$$)
   my $content = &{$self->formatting_function('format_contents')}($self,
                                                           $cmdname, $command);
   if ($content) {
-    my $special_element_type = $contents_command_element_type{$cmdname};
-    my $special_element_direction
-      = 
$self->get_conf('SPECIAL_ELEMENTS_DIRECTIONS')->{$special_element_type};
-    my $special_element
-      = $self->special_direction_element($special_element_direction);
-    my $class = 
$self->get_conf('SPECIAL_ELEMENTS_CLASS')->{$special_element_type};
+    my ($special_element_type, $special_element, $class_base,
+        $special_element_direction)
+          = $self->command_name_special_element_information($cmdname);
     # FIXME is element- the best prefix?
-    my $result = $self->html_attribute_class('div', ["element-${class}"]);
+    my $result = $self->html_attribute_class('div', ["element-${class_base}"]);
     my $heading;
     if ($special_element) {
       my $id = $self->command_id($special_element);
@@ -4996,7 +5011,7 @@ sub _contents_inline_element($$$)
     }
     $result .= ">\n";
     $result .= &{$self->formatting_function('format_heading_text')}($self,
-                                  $cmdname, [$class.'-heading'], $heading,
+                                  $cmdname, [$class_base.'-heading'], $heading,
                                   
$self->get_conf('CHAPTER_HEADER_LEVEL'))."\n";
     $result .= $content . "</div>\n";
     return $result;
@@ -6063,8 +6078,8 @@ sub _convert_special_element_type($$$$)
   my $special_element_type = $element->{'extra'}->{'special_element_type'};
   $result .= join('', $self->close_registered_sections_level(0));
   my $id = $self->command_id($element);
-  my $class = 
$self->get_conf('SPECIAL_ELEMENTS_CLASS')->{$special_element_type};
-  $result .= $self->html_attribute_class('div', ["element-${class}"]);
+  my $class_base = 
$self->get_conf('SPECIAL_ELEMENTS_CLASS')->{$special_element_type};
+  $result .= $self->html_attribute_class('div', ["element-${class_base}"]);
   if ($id ne '') {
     $result .= " id=\"$id\"";
   }
@@ -6082,7 +6097,7 @@ sub _convert_special_element_type($$$$)
     $level = $self->get_conf('FOOTNOTE_SEPARATE_HEADER_LEVEL');
   }
   $result .= &{$self->formatting_function('format_heading_text')}($self,
-                           undef, [$class.'-heading'], $heading, $level)."\n";
+                           undef, [$class_base.'-heading'], $heading, 
$level)."\n";
 
   my $special_element_body
     .= &{$self->formatting_function('format_special_element_body')}($self,
@@ -7346,13 +7361,15 @@ sub _html_get_tree_root_element($$;$)
         die "Problem $root_element, $root_command" if (defined($root_element)
                                                   or defined($root_command));
         return (undef, undef);
-      } elsif ($current->{'cmdname'} eq 'footnote' 
-               and $self->special_direction_element('Footnotes')
-               and $find_container) {
-         # in that case there is no root_command
-         #print STDERR "SPECIAL footnote\n" if ($debug);
-         $root_element = $self->special_direction_element('Footnotes');
-         return ($root_element);
+      } elsif ($find_container) {
+        # @footnote and possibly @*contents when a separate element is set
+        my ($special_element_type, $special_element, $class_base,
+            $special_element_direction)
+         = 
$self->command_name_special_element_information($current->{'cmdname'});
+        if ($special_element) {
+          #print STDERR "SPECIAL $current->{'cmdname'}: $special_element_type 
($special_element_direction)\n" if ($debug);
+          return ($special_element);
+        }
       }
     }
     if ($current->{'structure'}



reply via email to

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