texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Convert/HTML.pm t/init/redef...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/HTML.pm t/init/redef...
Date: Sun, 09 Oct 2011 00:49:38 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/10/09 00:49:38

Modified files:
        tp/Texinfo/Convert: HTML.pm 
        tp/t/init      : redefine_need.init 
Added files:
        tp/init        : book.pm 

Log message:
        Prepend format_ to formatting functions key names.
        export default formatting functions to users.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.176&r2=1.177
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/init/book.pm?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/init/redefine_need.init?cvsroot=texinfo&r1=1.1&r2=1.2

Patches:
Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -b -r1.176 -r1.177
--- Texinfo/Convert/HTML.pm     8 Oct 2011 20:04:45 -0000       1.176
+++ Texinfo/Convert/HTML.pm     9 Oct 2011 00:49:37 -0000       1.177
@@ -575,6 +575,13 @@
   return $self->{'global_target_elements'}->{$type};
 }
 
+sub default_formatting_function($$)
+{
+  my $self = shift;
+  my $format = shift;
+  return $self->{'default_formatting_functions'}->{'format_'.$format};
+}
+
 # see http://www.w3.org/TR/REC-html40/types.html#type-links
 # see http://www.w3.org/TR/REC-html40/types.html#type-links
 my %BUTTONS_REL =
@@ -1682,7 +1689,7 @@
   if ($self->in_string()) {
     return $text;
   }
-  return &{$self->{'heading_text'}}($self, 'titlefont', $text, 0, $command);
+  return &{$self->{'format_heading_text'}}($self, 'titlefont', $text, 0, 
$command);
 }
 
 $default_commands_conversion{'titlefont'} = \&_convert_titlefont_command;
@@ -1696,7 +1703,7 @@
 sub protect_text($$) {
   my $self = shift;
   my $text = shift;
-  return &{$self->{'protect_text'}}($self, $text);
+  return &{$self->{'format_protect_text'}}($self, $text);
 }
 
 sub _default_protect_text($$) {
@@ -1868,7 +1875,7 @@
         and defined($self->get_conf('ACTIVE_ICONS')->{$button})
         and $self->get_conf('ACTIVE_ICONS')->{$button} ne '') {
       my $button_name = $self->get_conf('BUTTONS_NAME')->{$button};
-      $active = &{$self->{'button_icon_img'}}($self, $button_name, 
+      $active = &{$self->{'format_button_icon_img'}}($self, $button_name, 
                                        $self->get_conf('ACTIVE_ICONS')->{' '});
     } else {
       $active = $self->get_conf('BUTTONS_TEXT')->{$button};
@@ -1904,7 +1911,7 @@
             and defined($button_name)) {
           # use icon
           $active = "<a href=\"$href\"${btitle}>".
-             &{$self->{'button_icon_img'}}($self, $button_name, $active_icon,
+             &{$self->{'format_button_icon_img'}}($self, $button_name, 
$active_icon,
                       $self->_element_direction($self->{'current_element'},
                                        $button, 'string')) ."</a>";
           $use_icon = 1;
@@ -1923,7 +1930,7 @@
         my $passive_icon = $self->get_conf('PASSIVE_ICONS')->{$button};
         my $button_name = $self->get_conf('BUTTONS_NAME')->{$button};
         if ($passive_icon and $passive_icon ne '') {
-          $passive = &{$self->{'button_icon_img'}}($self, $button_name, 
+          $passive = &{$self->{'format_button_icon_img'}}($self, $button_name, 
                                                    $passive_icon,
                       $self->_element_direction($self->{'current_element'},
                                        $button, 'string'));
@@ -1977,7 +1984,7 @@
       $direction = $button;
     }
 
-    my ($active, $passive) = &{$self->{'button_formatting'}}($self, $button);
+    my ($active, $passive) = &{$self->{'format_button'}}($self, $button);
     if ($self->get_conf('HEADER_IN_TABLE')) {
       if (defined($active)) {
         $first_button = 0 if ($first_button);
@@ -2021,7 +2028,7 @@
 <td align="left">
 ';
   }
-  $result .= &{$self->{'navigation_header_panel'}}($self, $buttons,
+  $result .= &{$self->{'format_navigation_header_panel'}}($self, $buttons,
                                                    $cmdname, $command,
                                    
$self->get_conf('VERTICAL_HEAD_NAVIGATION'));
   if ($self->get_conf('VERTICAL_HEAD_NAVIGATION')) {
@@ -2049,35 +2056,15 @@
              and $element->{'extra'}->{'element_command'}->{'cmdname'} eq 
'node')));
 }
 
-sub _convert_heading_command($$$$$)
+sub _default_element_header($$$$)
 {
   my $self = shift;
   my $cmdname = shift;
   my $command = shift;
-  my $args = shift;
-  my $content = shift;
+  my $element = shift;
 
   my $result = '';
 
-  # not clear that it may really happen
-  if ($self->in_string) {
-    $result .= $self->command_string($command) ."\n" if ($cmdname ne 'node');
-    $result .= $content if (defined($content));
-    return $result;
-  }
-
-  my $element_id = $self->command_id($command);
-  $result .= "<a name=\"$element_id\"></a>\n" 
-    if (defined($element_id) and $element_id ne '');
-
-  print STDERR "Process $command "
-        .Texinfo::Structuring::_print_root_command_texi($command)."\n"
-          if ($self->get_conf('DEBUG'));
-  my $element;
-  if ($root_commands{$command->{'cmdname'}} and $command->{'parent'}
-      and $command->{'parent'}->{'type'} 
-      and $command->{'parent'}->{'type'} eq 'element') {
-    $element = $command->{'parent'};
     print STDERR "Element $element (@{$element->{'contents'}}) ".
        Texinfo::Structuring::_print_element_command_texi($element) ."\n"
           if ($self->get_conf('DEBUG'));
@@ -2103,35 +2090,72 @@
         # FIXME clarify this
         # this is here because we want to always print the head navigation for 
top
         # and use TOP_BUTTONS
-        $result .= &{$self->{'navigation_header'}}($self, 
+      $result .= &{$self->{'format_navigation_header'}}($self, 
                  $self->get_conf('TOP_BUTTONS'), $cmdname, $command)
          if ($self->get_conf('SPLIT') or $self->get_conf('HEADERS'));
       } else {
         if ($first_in_page and !$self->get_conf('HEADERS')) {
           if ($self->get_conf('SPLIT') eq 'chapter') {
-            $result .= &{$self->{'navigation_header'}}($self, 
+          $result .= &{$self->{'format_navigation_header'}}($self, 
                   $self->get_conf('CHAPTER_BUTTONS'), $cmdname, $command);
             $result .= $self->get_conf('DEFAULT_RULE') ."\n"
               if (defined($self->get_conf('DEFAULT_RULE'))
                   and !$self->get_conf('VERTICAL_HEAD_NAVIGATION'));
           } elsif ($self->get_conf('SPLIT') eq 'section') {
-            $result .= &{$self->{'navigation_header'}}($self, 
+          $result .= &{$self->{'format_navigation_header'}}($self, 
                   $self->get_conf('SECTION_BUTTONS'), $cmdname, $command);
           }
         }
         if (($first_in_page or $previous_is_top) 
              and ($self->get_conf('HEADERS'))) {
-          $result .= &{$self->{'navigation_header'}}($self, 
+        $result .= &{$self->{'format_navigation_header'}}($self, 
                   $self->get_conf('SECTION_BUTTONS'), $cmdname, $command);
         } else {
           # got to do this here, as it isn't done otherwise since 
           # header_navigation is not called
-          $result .= &{$self->{'navigation_header_panel'}}($self,
+        $result .= &{$self->{'format_navigation_header_panel'}}($self,
                   $self->get_conf('SECTION_BUTTONS'), $cmdname, $command)
             if ($self->get_conf('HEADERS') or $self->get_conf('SPLIT') eq 
'node');
         }
       }
     }
+  return $result;
+}
+
+sub _convert_heading_command($$$$$)
+{
+  my $self = shift;
+  my $cmdname = shift;
+  my $command = shift;
+  my $args = shift;
+  my $content = shift;
+
+  my $result = '';
+
+  # not clear that it may really happen
+  if ($self->in_string) {
+    $result .= $self->command_string($command) ."\n" if ($cmdname ne 'node');
+    $result .= $content if (defined($content));
+    return $result;
+  }
+
+  my $element_id = $self->command_id($command);
+  $result .= "<a name=\"$element_id\"></a>\n" 
+    if (defined($element_id) and $element_id ne '');
+
+  print STDERR "Process $command "
+        .Texinfo::Structuring::_print_root_command_texi($command)."\n"
+          if ($self->get_conf('DEBUG'));
+  my $element;
+  if ($Texinfo::Common::root_commands{$command->{'cmdname'}} 
+      and $command->{'parent'}
+      and $command->{'parent'}->{'type'} 
+      and $command->{'parent'}->{'type'} eq 'element') {
+    $element = $command->{'parent'};
+  }
+  if ($element) {
+    $result .= &{$self->{'format_element_header'}}($self, $cmdname, 
+                                            $command, $element);
   }
 
   my $heading_level;
@@ -2158,8 +2182,9 @@
   # if there is an error in the node.
   if (defined($heading) and $heading ne '' and defined($heading_level)) {
 
-    if ($self->get_conf('TOC_LINKS') and $root_commands{$cmdname}
-        and $sectioning_commands{$cmdname}) {
+    if ($self->get_conf('TOC_LINKS')
+        and $Texinfo::Common::root_commands{$cmdname}
+        and $Texinfo::Common::sectioning_commands{$cmdname}) {
       my $content_href = $self->command_contents_href($command, 'contents',
                                         $self->{'current_filename'});
       if ($content_href) {
@@ -2176,7 +2201,7 @@
         $cmdname 
           = 
$Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
       }
-      $result .= &{$self->{'heading_text'}}($self, $cmdname, $heading, 
+      $result .= &{$self->{'format_heading_text'}}($self, $cmdname, $heading, 
                                             $heading_level, $command);
     }
   }
@@ -3226,7 +3251,7 @@
   my $cmdname = shift;
   my $command = shift;
 
-  my $content = $self->{'contents'}($self, $cmdname, $command);
+  my $content = &{$self->{'format_contents'}}($self, $cmdname, $command);
   if ($content) {
     my $result = '';
     my $special_element 
@@ -3245,7 +3270,7 @@
       $heading 
         = $self->convert_tree 
($self->get_conf('SPECIAL_ELEMENTS_NAME')->{$element_name});
     }
-    $result .= &{$self->{'heading_text'}}($self, $cmdname, $heading, 0)."\n";
+    $result .= &{$self->{'format_heading_text'}}($self, $cmdname, $heading, 
0)."\n";
     $result .= $content . "\n";
     return $result;
   }
@@ -3869,7 +3894,7 @@
   if (!$command->{'parent'} 
       or !$command->{'parent'}->{'type'}
       or $command->{'parent'}->{'type'} ne 'element') {
-    $result .= &{$self->{'footnotes_text'}}($self);
+    $result .= &{$self->{'format_footnotes_text'}}($self);
     $result .= $self->get_conf('DEFAULT_RULE') ."\n",
       if ($self->get_conf('PROGRAM_NAME_IN_FOOTER') 
           and defined($self->get_conf('DEFAULT_RULE'))
@@ -3914,7 +3939,7 @@
     $self->_new_document_context('simpletitle_string');
     my $title_text = $self->convert_tree($self->{'simpletitle_tree'});
     pop @{$self->{'document_context'}};
-    $titlepage_text = &{$self->{'heading_text'}}($self, 'settitle', 
$title_text, 
+    $titlepage_text = &{$self->{'format_heading_text'}}($self, 'settitle', 
$title_text, 
                                             0, {'cmdname' => 'settitle',
                      'contents' => $self->{'simpletitle_tree'}->{'contents'}});
   }
@@ -3932,13 +3957,13 @@
   my $result = '';
   if ($self->get_conf('SHOW_TITLE')) {
     if ($self->get_conf('USE_TITLEPAGE_FOR_TITLE')) {
-      $result .= &{$self->{'titlepage'}}($self);
+      $result .= &{$self->{'format_titlepage'}}($self);
     } else {
       if ($self->{'simpletitle_tree'}) {
        $self->_new_document_context('simpletitle_string');
         my $title_text = $self->convert_tree($self->{'simpletitle_tree'});
         pop @{$self->{'document_context'}};
-        $result .= &{$self->{'heading_text'}}($self, 'settitle', $title_text, 
+        $result .= &{$self->{'format_heading_text'}}($self, 'settitle', 
$title_text, 
                                             0, {'cmdname' => 'settitle',
                      'contents' => $self->{'simpletitle_tree'}->{'contents'}});
       }
@@ -3981,14 +4006,14 @@
     if ($self->get_conf('HEADERS') 
         # first in page
         or $self->{'counter_in_file'}->{$element->{'filename'}} == 1) {
-      $result .= &{$self->{'navigation_header'}}($self, 
+      $result .= &{$self->{'format_navigation_header'}}($self, 
                  $self->get_conf('MISC_BUTTONS'), undef, $element);
       
     }
     my $heading = $self->command_text($element);
-    $result .= &{$self->{'heading_text'}}($self, '', $heading, 0)."\n";
+    $result .= &{$self->{'format_heading_text'}}($self, '', $heading, 0)."\n";
 
-    my $special_element_body .= &{$self->{'special_element_body'}}($self, 
+    my $special_element_body .= 
&{$self->{'format_special_element_body'}}($self, 
                                                  $special_element, $element);
     # This may happen with footnotes in regions that are not expanded,
     # like @copying or @titlepage
@@ -4000,7 +4025,7 @@
     $result .= $self->_print_title();
     if (!$element->{'element_next'}) {
       # only one element
-      my $foot_text = &{$self->{'footnotes_text'}}($self);
+      my $foot_text = &{$self->{'format_footnotes_text'}}($self);
       return $result.$content.$foot_text.$self->get_conf('DEFAULT_RULE')."\n";
     }
   }
@@ -4085,7 +4110,7 @@
        or (defined($element->{'filename'})
            and $element->{'filename'} ne 
$element->{'element_next'}->{'filename'}))
       and $self->get_conf('footnotestyle') eq 'end') {
-    $result .= &{$self->{'footnotes_text'}}($self);
+    $result .= &{$self->{'format_footnotes_text'}}($self);
   }
   if (!$self->get_conf('PROGRAM_NAME_IN_FOOTER') 
       and !$buttons and !$maybe_in_page) {
@@ -4094,7 +4119,7 @@
     $result .= "$rule\n" if ($rule);
   }
   if ($buttons) {
-    $result .= &{$self->{'navigation_header_panel'}}($self, $buttons,
+    $result .= &{$self->{'format_navigation_header_panel'}}($self, $buttons,
                                                      undef, $element);
   }
   
@@ -4244,35 +4269,38 @@
   }
 
   foreach my $formatting_references (
-     ['heading_text', \&_default_heading_text, $Texinfo::Config::heading_text],
-     ['comment', \&_default_comment, $Texinfo::Config::comment],
-     ['protect_text', \&_default_protect_text, $Texinfo::Config::protect_text],
-     ['css_lines', \&_default_css_lines, $Texinfo::Config::css_lines],
-     ['begin_file', \&_default_begin_file, $Texinfo::Config::begin_file],
-     ['node_redirection_page', \&_default_node_redirection_page, 
+     ['format_heading_text', \&_default_heading_text, 
$Texinfo::Config::heading_text],
+     ['format_comment', \&_default_comment, $Texinfo::Config::comment],
+     ['format_protect_text', \&_default_protect_text, 
$Texinfo::Config::protect_text],
+     ['format_css_lines', \&_default_css_lines, $Texinfo::Config::css_lines],
+     ['format_begin_file', \&_default_begin_file, 
$Texinfo::Config::begin_file],
+     ['format_node_redirection_page', \&_default_node_redirection_page, 
                                $Texinfo::Config::node_redirection_page],
-     ['end_file', \&_default_end_file, $Texinfo::Config::end_file],
-     ['special_element_body', \&_default_special_element_body, 
+     ['format_end_file', \&_default_end_file, $Texinfo::Config::end_file],
+     ['format_special_element_body', \&_default_special_element_body, 
                               $Texinfo::Config::special_element_body],
-     ['footnotes_text', \&_default_footnotes_text, 
+     ['format_footnotes_text', \&_default_footnotes_text, 
                          $Texinfo::Config::footnotes_text],
-     ['program_string', \&_default_program_string, 
+     ['format_program_string', \&_default_program_string, 
                          $Texinfo::Config::program_string],
-     ['titlepage', \&_default_titlepage, $Texinfo::Config::titlepage],
-     ['navigation_header', \&_default_navigation_header, 
+     ['format_titlepage', \&_default_titlepage, $Texinfo::Config::titlepage],
+     ['format_navigation_header', \&_default_navigation_header, 
                                    $Texinfo::Config::navigation_header],
-     ['navigation_header_panel', \&_default_navigation_header_panel, 
+     ['format_navigation_header_panel', \&_default_navigation_header_panel, 
                               $Texinfo::Config::navigation_header_panel],
-     ['button_formatting', \&_default_button_formatting, 
+     ['format_element_header', \&_default_element_header,
+                              $Texinfo::Config::element_header],
+     ['format_button', \&_default_button_formatting, 
                                     $Texinfo::Config::button_formatting],
-     ['button_icon_img', \&_default_button_icon_img, 
+     ['format_button_icon_img', \&_default_button_icon_img, 
                                       $Texinfo::Config::button_icon_img],
-     ['external_href', \&_default_external_href, 
+     ['format_external_href', \&_default_external_href, 
                                     $Texinfo::Config::external_href],
-     ['contents', \&_default_contents, $Texinfo::Config::contents],
+     ['format_contents', \&_default_contents, $Texinfo::Config::contents],
   ) {
+    $self->{'default_formatting_functions'}->{$formatting_references->[0]}
+       = $formatting_references->[1];
     if (defined($formatting_references->[2])) {
-      # FIXME this pollutes the main converter keys space!
       $self->{$formatting_references->[0]} = $formatting_references->[2];
     } else {
       $self->{$formatting_references->[0]} = $formatting_references->[1];
@@ -4483,7 +4511,7 @@
   $self->{'css_import_lines'} = address@hidden;
   $self->{'css_rule_lines'} = address@hidden;
 
-  &{$self->{'css_lines'}}($self);
+  &{$self->{'format_css_lines'}}($self);
 }
 
 sub _node_id_file($$)
@@ -5616,7 +5644,7 @@
   my $self = shift;
   my $program_text = '';
   if ($self->get_conf('PROGRAM_NAME_IN_FOOTER')) {
-    my $program_string = &{$self->{'program_string'}}($self);
+    my $program_string = &{$self->{'format_program_string'}}($self);
     $program_text = " <font size=\"-1\">
   $program_string
  </font>
@@ -5827,9 +5855,9 @@
          and $self->get_conf('DEFAULT_RULE') ne '');
   my $footnote_heading 
     = $self->convert_tree 
($self->get_conf('SPECIAL_ELEMENTS_NAME')->{'Footnotes'});
-  $result .= &{$self->{'heading_text'}}($self, 'footnote', 
+  $result .= &{$self->{'format_heading_text'}}($self, 'footnote', 
                                         $footnote_heading, 3)."\n";
-  $result .= &{$self->{'special_element_body'}}($self, 'Footnotes',
+  $result .= &{$self->{'format_special_element_body'}}($self, 'Footnotes',
                                                $self->{'current_element'});
   $result .= "</div>\n";
   return $result;
@@ -5851,7 +5879,7 @@
         $about .= $PRE_ABOUT;
       }
     } else {
-      $about .= '  '.&{$self->{'program_string'}}($self) ."\n";
+      $about .= '  '.&{$self->{'format_program_string'}}($self) ."\n";
     }
     $about .= <<EOT;
 </p>
@@ -5875,7 +5903,7 @@
       $about .= "  <tr>\n    <td align=\"center\">";
       $about .=
             ($self->get_conf('ICONS') && 
$self->get_conf('ACTIVE_ICONS')->{$button} ?
-             &{$self->{'button_icon_img'}}($self, $button_name, 
+             &{$self->{'format_button_icon_img'}}($self, $button_name, 
                                        
$self->get_conf('ACTIVE_ICONS')->{$button}) :
              ' [' . $self->get_conf('BUTTONS_TEXT')->{$button} . '] ');
       $about .= "</td>\n";
@@ -5942,9 +5970,9 @@
 EOT
     return $about;
   } elsif ($special_type eq 'Contents') {
-    return $self->{'contents'}($self, 'contents', undef);
+    return &{$self->{'format_contents'}}($self, 'contents', undef);
   } elsif ($special_type eq 'Overview') {
-    return $self->{'contents'}($self, 'shortcontents', undef);
+    return &{$self->{'format_contents'}}($self, 'shortcontents', undef);
   } elsif ($special_type eq 'Footnotes') {
     my $result = $foot_lines;
     $foot_lines = '';
@@ -6120,7 +6148,7 @@
      {'contents' => $self->{'extra'}->{'copying'}->{'contents'}}, 
      {Texinfo::Common::_convert_text_options($self)});
     if ($copying_comment ne '') {
-      $self->{'copying_comment'} = &{$self->{'comment'}}($self, 
$copying_comment);
+      $self->{'copying_comment'} = &{$self->{'format_comment'}}($self, 
$copying_comment);
     }
   }
 
@@ -6154,7 +6182,7 @@
         if ($self->get_conf('DEBUG'));
     }
     $self->{'current_filename'} = $self->{'output_filename'};
-    my $header = &{$self->{'begin_file'}}($self, $self->{'output_filename'}, 
undef);
+    my $header = &{$self->{'format_begin_file'}}($self, 
$self->{'output_filename'}, undef);
     $output .= $self->_output_text($header, $fh);
     if ($elements and @$elements) {
       foreach my $element (@$elements) {
@@ -6165,7 +6193,7 @@
       $output .= $self->_output_text($self->_print_title(), $fh);
       $output .= $self->_output_text($self->_convert($root), $fh);
     }
-    $output .= $self->_output_text(&{$self->{'end_file'}}($self), $fh);
+    $output .= $self->_output_text(&{$self->{'format_end_file'}}($self), $fh);
     return $output if ($self->get_conf('OUTFILE') eq '');
   } else {
     # output with pages
@@ -6200,7 +6228,7 @@
           # FIXME close/remove files already created
           return undef;
         }
-        print $file_fh "".&{$self->{'begin_file'}}($self, 
+        print $file_fh "".&{$self->{'format_begin_file'}}($self, 
                                            $element->{'filename'}, 
                                            $element);
         $files{$element->{'filename'}}->{'fh'} = $file_fh;
@@ -6216,7 +6244,7 @@
       $self->{'file_counters'}->{$element->{'filename'}}--;
       if ($self->{'file_counters'}->{$element->{'filename'}} == 0) {
         # end file
-        print $file_fh "". &{$self->{'end_file'}}($self);
+        print $file_fh "". &{$self->{'format_end_file'}}($self);
       }
     }
   }
@@ -6246,7 +6274,7 @@
       #}
       if (defined($filename) and $node_filename ne $filename) {
         my $redirection_page 
-          = &{$self->{'node_redirection_page'}}($self, $node);
+          = &{$self->{'format_node_redirection_page'}}($self, $node);
         my $out_filename;
         if (defined($self->{'destination_directory'})) {
           $out_filename = $self->{'destination_directory'} 
@@ -6300,7 +6328,7 @@
           if (defined($self->get_conf('NODE_FILE_EXTENSION')) 
             and $self->get_conf('NODE_FILE_EXTENSION') ne '');
         my $redirection_page 
-          = &{$self->{'node_redirection_page'}}($self, 
+          = &{$self->{'format_node_redirection_page'}}($self, 
                        $self->label_command($parsed_new_node->{'normalized'}));
         my $out_filename;
         if (defined($self->{'destination_directory'})) {

Index: t/init/redefine_need.init
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/init/redefine_need.init,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- t/init/redefine_need.init   4 Sep 2011 13:41:45 -0000       1.1
+++ t/init/redefine_need.init   9 Oct 2011 00:49:38 -0000       1.2
@@ -22,5 +22,5 @@
   } else {
     $arg_text = '';
   }
-  return (&{$converter->{'comment'}}($converter, "$cmdname: $arg_text"));
+  return (&{$converter->{'format_comment'}}($converter, "$cmdname: 
$arg_text"));
 }

Index: init/book.pm
===================================================================
RCS file: init/book.pm
diff -N init/book.pm
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ init/book.pm        9 Oct 2011 00:49:38 -0000       1.1
@@ -0,0 +1,270 @@
+# A style that tries to be analogous with a book, in HTML.
+#
+# This file is in the public domain. Thus it may easily be used as an 
+# example for further customizations.
+#
+# Originally written by Patrice Dumas in 2004.
+# Modified in 2007, 2008.
+#
+# This style is based on the scriptbasic style.
+
+use strict;
+
+use vars qw(%commands_conversion $navigation_header $element_file_name);
+
+set_from_init_file('contents', 1);
+set_from_init_file('INLINE_CONTENTS', 1);
+set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
+
+my @book_buttons = ('Back', 'Forward', ' ', 'Contents', 'Index', 'About');
+
+foreach my $buttons ('SECTION_BUTTONS', 'CHAPTER_BUTTONS', 'TOP_BUTTONS') {
+  set_from_init_file($buttons, address@hidden);
+}
+
+my @book_footer_buttons = ('Contents', 'Index', 'About');
+foreach my $buttons ('MISC_BUTTONS', 'SECTION_FOOTER_BUTTONS') {
+  set_from_init_file($buttons, address@hidden);
+}
+
+set_from_init_file('NODE_FOOTER_BUTTONS', ['Back', 'Forward']);
+set_from_init_file('LINKS_BUTTONS', 
+    ['Top', 'Index', 'Contents', 'About', 'Up', 'NextFile', 'PrevFile']);
+
+set_from_init_file('WORDS_IN_PAGE', undef);
+set_from_init_file('SHOW_MENU', 0);
+set_from_init_file('USE_NODES', undef);
+set_from_init_file('USE_SECTIONS', 1);
+
+
+set_from_init_file('BIG_RULE', '<hr>');
+
+my $NO_BULLET_LIST_CLASS = 'no-bullet';
+
+
+sub book_print_up_toc($$)
+{
+  my $converter = shift;
+  my $command = shift;
+
+  my $result = '';
+  my $current_command = $command;
+  my @up_commands;
+  while (defined($current_command->{'section_up'}) 
+           and ($current_command->{'section_up'} ne $current_command)
+           and defined($current_command->{'section_up'}->{'cmdname'})) {
+    unshift (@up_commands, $current_command->{'section_up'});
+    $current_command = $current_command->{'section_up'};
+  }
+  # this happens for example for top element
+  return '' if !(@up_commands);
+  #print $fh "<ul>" . &$anchor('', $Texi2HTML::HREF{Contents}, '[' . 
$Texi2HTML::NAME{Contents} . ']') . " <br>\n";
+  my $up = shift @up_commands;
+#print STDERR "$up $up->{'cmdname'} 
".Texinfo::Structuring::_print_root_command_texi($up)."\n";
+  $result .= $converter->_attribute_class('ul', $NO_BULLET_LIST_CLASS)."><li>" 
+  . "<a 
href=\"".$converter->command_href($up)."\">".$converter->command_text($up) 
+   . "</a> </li>\n";
+  foreach my $up (@up_commands) {
+    $result .= '<li>'
+    .$converter->_attribute_class('ul', $NO_BULLET_LIST_CLASS)."><li>"
+    . "<a 
href=\"".$converter->command_href($up)."\">".$converter->command_text($up) 
+   . "</a> </li>\n";
+  }
+  foreach my $up (@up_commands) {
+    $result .= "</ul></li>\n";
+  }
+  $result .= "</ul>\n";
+  return $result;
+}
+
+sub book_navigation_header($$$$)
+{
+  my $self = shift;
+  my $buttons = shift;
+  my $cmdname = shift;
+  my $command = shift;
+
+  my $element = $command->{'parent'};
+  if ($element 
+      and $element->{'extra'}->{'section'}
+      and ($element->{'contents'}->[0] eq $command
+          or (!$element->{'contents'}->[0]->{'cmdname'} 
+              and $element->{'contents'}->[1] eq $command))
+      and defined($element->{'filename'})
+      and $self->{'counter_in_file'}->{$element->{'filename'}} == 1) {
+    
+    return book_print_up_toc($self, $element->{'extra'}->{'section'}) .
+       &{$self->default_formatting_function('navigation_header')}($self,
+                                 $buttons, $cmdname, $command);
+
+  } else {
+    return &{$self->default_formatting_function('navigation_header')}($self, 
+             $buttons, $cmdname, $command);
+  }
+}
+
+$navigation_header = \&book_navigation_header;
+
+sub book_print_sub_toc($$$);
+
+sub book_print_sub_toc($$$)
+{
+  my $converter = shift;
+  my $parent_command = shift;
+  my $command = shift;
+
+  my $result = '';
+  my $content_href = $converter->command_href($command);
+  my $heading = $converter->command_text($command);
+  if ($content_href) {
+    $result .= "<li> "."<a href=\"$content_href\">$heading</a>" . " </li>\n";
+  }
+#print STDERR "SUB_TOC $element->{'text'}\n"; #sleep 1;
+  if ($command->{'section_childs'} and @{$command->{'section_childs'}}) {
+#print STDERR "SUB_TOC child $element->{'child'}->{'text'}\n"; 
+    $result .= '<li>'.$converter->_attribute_class('ul',$NO_BULLET_LIST_CLASS)
+     .">\n". book_print_sub_toc($converter, $parent_command, 
+                                $command->{'section_childs'}->[0]) 
+     ."</ul></li>\n";
+  }
+  if (exists($command->{'section_next'})) {
+#print STDERR "SUB_TOC next($element->{'text'}) 
$element->{'next'}->{'text'}\n"; 
+    $result .= book_print_sub_toc($converter, $parent_command, 
+                                  $command->{'section_next'});
+  }
+  return $result;
+}
+
+sub book_convert_heading_command($$$$$)
+{
+  my $self = shift;
+  my $cmdname = shift;
+  my $command = shift;
+  my $args = shift;
+  my $content = shift;
+
+  my $result = '';
+
+  # not clear that it may really happen
+  if ($self->in_string) {
+    $result .= $self->command_string($command) ."\n" if ($cmdname ne 'node');
+    $result .= $content if (defined($content));
+    return $result;
+  }
+  my $element_id = $self->command_id($command);
+  $result .= "<a name=\"$element_id\"></a>\n"
+    if (defined($element_id) and $element_id ne '');
+
+  print STDERR "Process $command "
+        .Texinfo::Structuring::_print_root_command_texi($command)."\n"
+          if ($self->get_conf('DEBUG'));
+  my $element;
+  if ($Texinfo::Common::root_commands{$command->{'cmdname'}} 
+      and $command->{'parent'}
+      and $command->{'parent'}->{'type'}
+      and $command->{'parent'}->{'type'} eq 'element') {
+    $element = $command->{'parent'};
+  }
+  if ($element) {
+    $result .= &{$self->{'format_element_header'}}($self, $cmdname,
+                                            $command, $element);
+  }
+
+  my $heading_level;
+  # FIXME this is done as in texi2html: node is used as heading if there 
+  # is nothing else.  Is it right?
+  if ($cmdname eq 'node') {
+    if (!$element or (!$element->{'extra'}->{'section'}
+                      and $element->{'extra'}->{'node'}
+                      and $element->{'extra'}->{'node'} eq $command
+                      # bogus node may not have been normalized
+                      and defined($command->{'extra'}->{'normalized'}))) {
+      if ($command->{'extra'}->{'normalized'} eq 'Top') {
+        $heading_level = 0;
+      } else {
+        $heading_level = 3;
+      }
+    }
+  } else {
+    $heading_level = $command->{'level'};
+  }
+
+  my $heading = $self->command_text($command);
+  # $heading not defined may happen if the command is a @node, for example
+  # if there is an error in the node.
+  if (defined($heading) and $heading ne '' and defined($heading_level)) {
+
+    if ($self->get_conf('TOC_LINKS')
+        and $Texinfo::Common::root_commands{$cmdname}
+        and $Texinfo::Common::sectioning_commands{$cmdname}) {
+      my $content_href = $self->command_contents_href($command, 'contents',
+                                        $self->{'current_filename'});
+      if ($content_href) {
+        $heading = "<a href=\"$content_href\">$heading</a>";
+      }
+    }
+
+    if ($self->in_preformatted()) {
+      $result .= '<strong>'.$heading.'</strong>'."\n";
+    } else {
+      # if the level was changed, set the command name right
+      if ($cmdname ne 'node'
+          and $heading_level ne 
$Texinfo::Common::command_structuring_level{$cmdname}) {
+        $cmdname
+          = 
$Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
+      }
+      $result .= &{$self->{'format_heading_text'}}($self, $cmdname, $heading,
+                                            $heading_level, $command);
+    }
+  }
+  if ($command->{'section_childs'} and @{$command->{'section_childs'}}
+      and $cmdname ne 'top') {
+    $result .= $self->_attribute_class('ul', $NO_BULLET_LIST_CLASS).">\n";
+    $result .= book_print_sub_toc($self, $command, 
+                                  $command->{'section_childs'}->[0]);
+    $result .= "</ul>\n";
+  }
+  $result .= $content if (defined($content));
+  return $result;
+}
+
+foreach my $command (keys(%Texinfo::Common::sectioning_commands), 'node') {
+  $commands_conversion{$command} = \&book_convert_heading_command;
+}
+
+sub book_element_file_name($$$)
+{
+  my $converter = shift;
+  my $element = shift;
+  my $filename = shift;
+
+  return undef if ($converter->get_conf('NODE_FILENAMES') 
+                   or !$converter->get_conf('SPLIT'));
+
+  if (defined($converter->{'book_previous_default_filename'}) 
+      and ($filename eq $converter->{'book_previous_default_filename'})) {
+    return $converter->{'book_previous_file_name'};
+  }
+
+  my $prefix = $converter->{'document_name'};
+  my $new_file_name;
+  my $command = $element->{'extra'}->{'section'};
+  return undef unless ($command);
+  if ($converter->_element_is_top($element)) {
+    $new_file_name = "${prefix}_top.html";
+  } elsif (defined($command->{'number'}) and ($command->{'number'} ne '')) {
+    my $number = $command->{'number'};
+    $number .= '.' unless ($number =~ /\.$/);
+    $new_file_name = "${prefix}_$number" . 'html';
+  } else {
+    $converter->{'book_unumbered_nr'}++;
+    $new_file_name = "${prefix}_U." . $converter->{'book_unumbered_nr'} . 
'.html';
+  }
+  $converter->{'book_previous_default_filename'} = $filename;
+  $converter->{'book_previous_file_name'} = $new_file_name;
+  return $new_file_name;
+}
+
+$element_file_name = \&book_element_file_name;
+
+1;



reply via email to

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