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


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_default_format_button): avoid 2 if for the most common case of ICONS not being set, instead recopy code.
Date: Sat, 06 Jan 2024 07:26:29 -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 dc4430590e * tp/Texinfo/Convert/HTML.pm (_default_format_button): 
avoid 2 if for the most common case of ICONS not being set, instead recopy code.
dc4430590e is described below

commit dc4430590ed3bf7711080a428e2a65acfa573890
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jan 6 13:26:30 2024 +0100

    * tp/Texinfo/Convert/HTML.pm (_default_format_button): avoid 2 if for
    the most common case of ICONS not being set, instead recopy code.
---
 ChangeLog                  |  5 +++++
 tp/Texinfo/Convert/HTML.pm | 56 ++++++++++++++++++++++++++--------------------
 2 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2bb6393860..74d8ca63ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-01-06  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_default_format_button): avoid 2 if for
+       the most common case of ICONS not being set, instead recopy code.
+
 2024-01-06  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c (preformatted_cmd_list)
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index ce89ff216c..8da7972ac6 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4301,18 +4301,20 @@ sub _default_format_button($$;$)
     }
   } elsif ($button eq ' ') {
     # handle space button
-    my $direction_icon;
     if ($self->get_conf('ICONS')) {
+      my $direction_icon;
       my $active_icons = $self->get_conf('ACTIVE_ICONS');
       if ($active_icons) {
         $direction_icon = $active_icons->{$button};
       }
-    }
-    if (defined($direction_icon) and $direction_icon ne '') {
-      my $button_name_string = $self->direction_string($button,
-                                                       'button', 'string');
-      $active = &{$self->formatting_function('format_button_icon_img')}($self,
-                                         $button_name_string, $direction_icon);
+      if (defined($direction_icon) and $direction_icon ne '') {
+        my $button_name_string = $self->direction_string($button,
+                                                        'button', 'string');
+        $active = 
&{$self->formatting_function('format_button_icon_img')}($self,
+                                           $button_name_string, 
$direction_icon);
+      } else {
+        $active = $self->direction_string($button, 'text');
+      }
     } else {
       $active = $self->direction_string($button, 'text');
     }
@@ -4339,21 +4341,25 @@ sub _default_format_button($$;$)
           $btitle .= " rel=\"$button_rel\"";
         }
       }
-      my $active_icon;
       if ($self->get_conf('ICONS')) {
+        my $active_icon;
         my $active_icons = $self->get_conf('ACTIVE_ICONS');
         if ($active_icons) {
         # FIXME strip FirstInFile from $button to get $active_icon?
           $active_icon = $active_icons->{$button};
         }
-      }
-      if (defined($active_icon) and $active_icon ne '') {
-        my $button_name_string = $self->direction_string($button,
-                                                         'button', 'string');
-        $active = "<a href=\"$href\"${btitle}>".
-           &{$self->formatting_function('format_button_icon_img')}($self,
-                    $button_name_string, $active_icon,
-                    $self->from_element_direction($button, 'string')) ."</a>";
+        if (defined($active_icon) and $active_icon ne '') {
+          my $button_name_string = $self->direction_string($button,
+                                                           'button', 'string');
+          $active = "<a href=\"$href\"${btitle}>".
+             &{$self->formatting_function('format_button_icon_img')}($self,
+                      $button_name_string, $active_icon,
+                      $self->from_element_direction($button, 'string')) 
."</a>";
+        } else {
+          # use text
+          $active = '[' . "<a href=\"$href\"${btitle}>".
+            $self->direction_string($button, 'text')."</a>" . ']';
+        }
       } else {
         # use text
         $active = '[' . "<a href=\"$href\"${btitle}>".
@@ -4361,21 +4367,23 @@ sub _default_format_button($$;$)
       }
     } else {
       # button is passive
-      my $passive_icon;
       if ($self->get_conf('ICONS')) {
+        my $passive_icon;
         my $passive_icons = $self->get_conf('PASSIVE_ICONS');
         if ($passive_icons) {
         # FIXME strip FirstInFile from $button to get $passive_icon?
           $passive_icon = $passive_icons->{$button};
         }
-      }
-      if (defined($passive_icon) and $passive_icon ne '') {
-        # FIXME strip FirstInFile from $button to get $passive_icon?
-        my $button_name_string = $self->direction_string($button,
+        if (defined($passive_icon) and $passive_icon ne '') {
+          # FIXME strip FirstInFile from $button to get $passive_icon?
+          my $button_name_string = $self->direction_string($button,
                                                          'button', 'string');
-        $passive = &{$self->formatting_function('format_button_icon_img')}(
-                    $self, $button_name_string, $passive_icon,
-                    $self->from_element_direction($button, 'string'));
+          $passive = &{$self->formatting_function('format_button_icon_img')}(
+                      $self, $button_name_string, $passive_icon,
+                      $self->from_element_direction($button, 'string'));
+        } else {
+          $passive = '[' . $self->direction_string($button, 'text') . ']';
+        }
       } else {
         $passive = '[' . $self->direction_string($button, 'text') . ']';
       }



reply via email to

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