texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...


From: Patrice Dumas
Subject: texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...
Date: Sun, 01 May 2011 15:15:47 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/05/01 15:15:47

Modified files:
        tp             : texi2any.pl 
        tp/Texinfo     : Common.pm 
        tp/Texinfo/Convert: HTML.pm 

Log message:
        Format About more like texi2html.
        Handle better inline contents.
        Fix refs to external nodes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.45&r2=1.46

Patches:
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- texi2any.pl 25 Apr 2011 17:56:31 -0000      1.37
+++ texi2any.pl 1 May 2011 15:15:46 -0000       1.38
@@ -420,7 +420,7 @@
 #  $INDEX_ENTRY_COLON = '';
 
   set_from_cmdline('ENABLE_ENCODING_USE_ENTITY', 1);
-  set_from_cmdline('DO_ABOUT', 1);
+  set_from_cmdline('DO_ABOUT', undef);
   set_from_cmdline('BIG_RULE', '<hr size="6">');
   set_from_cmdline('SECTION_BUTTONS', ['FastBack', 'Back', 'Up', 'Forward', 
'FastForward',
                              ' ', ' ', ' ', ' ',

Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- Texinfo/Common.pm   25 Apr 2011 17:56:32 -0000      1.41
+++ Texinfo/Common.pm   1 May 2011 15:15:47 -0000       1.42
@@ -128,14 +128,15 @@
   'TEXI2DVI', 'DUMP_TREE', 'MAX_MACRO_CALL_NESTING',
 # FIXME new
   'PROGRAM_AND_VERSION', 'PROGRAM_HOMEPAGE', 'PROGRAM',
-  'AFTER_BODY_OPEN', 'EXTRA_HEAD', 'LINKS_BUTTONS', 'DO_ABOUT',
+  'PRE_BODY_CLOSE', 'AFTER_BODY_OPEN', 'PRE_ABOUT', 'AFTER_ABOUT',
+  'EXTRA_HEAD', 'LINKS_BUTTONS', 'DO_ABOUT',
   'TOP_BUTTONS', 'SECTION_BUTTONS', 'BUTTONS_TEXT',
   'BUTTONS_ACCESSKEY', 'BUTTONS_REL', 'BUTTONS_GOTO',
   'CHAPTER_FOOTER_BUTTONS', 'SECTION_FOOTER_BUTTONS', 
   'NODE_FOOTER_BUTTONS',
   'MISC_BUTTONS', 'CHAPTER_BUTTONS', 'BUTTONS_NAME',
   'BUTTONS_EXAMPLE', 'SPECIAL_ELEMENTS_NAME',
-  'PRE_BODY_CLOSE', 'DEFAULT_RULE', 'BIG_RULE',
+  'DEFAULT_RULE', 'BIG_RULE',
   'MENU_ENTRY_COLON', 'MENU_SYMBOL', 'DO_ABOUT',
   'CSS_FILES', 'CSS_REFS');
 

Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- Texinfo/Convert/HTML.pm     30 Apr 2011 18:29:43 -0000      1.45
+++ Texinfo/Convert/HTML.pm     1 May 2011 15:15:47 -0000       1.46
@@ -149,6 +149,7 @@
   return $self->{'context'}->[-1]->{'align'}->[-1];
 }
 
+# API for the elements formatting
 sub command_id($$)
 {
   my $self = shift;
@@ -185,6 +186,7 @@
   }
 }
 
+# FIXME in the API?
 sub command_target($$)
 {
   my $self = shift;
@@ -242,6 +244,12 @@
   return $href;
 }
 
+my %contents_command_element_name = (
+  'contents' => 'Contents',
+  'shortcontents' => 'Overview',
+  'summarycontents' => 'Overview',
+);
+
 sub command_contents_href($$$$)
 {
   my $self = shift;
@@ -250,12 +258,7 @@
   my $filename = shift;
 
   my $href;
-  my $name;
-  if ($contents_or_shortcontents eq 'contents') {
-    $name = 'Contents';
-  } else {
-    $name = 'Overview';
-  }
+  my $name = $contents_command_element_name{$contents_or_shortcontents};
   
   my $target;
   if ($name eq 'Contents') {
@@ -264,7 +267,7 @@
     $target = $self->command_shortcontents_target($command);
   }
 
-  my $target_element = $self->{'special_elements'}->{$name};
+  my $target_element = $self->special_element($name);
   my $target_filename = $self->command_filename($target_element);
   if (defined($target_filename) and
       (!defined($filename)
@@ -335,6 +338,13 @@
   return $self->{'labels'}->{$label};
 }
 
+sub special_element($$)
+{
+  my $self = shift;
+  my $type = shift;
+  return $self->{'special_elements'}->{$type};
+}
+
 # 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 =
@@ -517,7 +527,8 @@
   foreach my $special_element (keys (%SPECIAL_ELEMENTS_NAME)) {
     if ($self->{'special_elements'}->{$special_element} and
         $self->{'targets'}->{$self->{'special_elements'}->{$special_element}}) 
{
-      my $target = 
$self->{'targets'}->{$self->{'special_elements'}->{$special_element}};
+      my $target 
+        = 
$self->{'targets'}->{$self->{'special_elements'}->{$special_element}};
       foreach my $key ('text', 'string', 'tree') {
         delete $target->{$key};
       }
@@ -1187,7 +1198,7 @@
                                            $button_href, 'href');
       if ($href) {
         my $anchor_attributes = 
$self->_direction_href_attributes($button_href);
-        $active =  "" . "<a href=\"$href\"${anchor_attributes}>$$text</a>";
+        $active = "<a href=\"$href\"${anchor_attributes}>$$text</a>";
       } else {
         $passive = $$text;
       }
@@ -1609,12 +1620,21 @@
   $self->_informative_command($command);
   if ($self->get_conf('INLINE_CONTENTS')) {
     if ($cmdname eq 'contents' or $cmdname eq 'shortcontents') {
+
+      my $content = $self->{'contents'}($self, $cmdname, $command);
+      if ($content) {
       my $result = '';
-      #my $result = "<a name=\"".$self->command_id
-      $result .= $self->{'contents'}($self, $cmdname, $command);
+        my $special_element 
+          = $self->special_element($contents_command_element_name{$cmdname});
+        my $id = $self->command_id($special_element);
+        $result .= "<a name=\"$id\"></a>\n";
+        my $heading = $self->command_text($special_element, 'text');
+        $result .= &{$self->{'heading_text'}}($self, $cmdname, $heading, 
0)."\n";
+        $result .= $content . "\n";
       return $result;
     }
   }
+  }
   return '';
 }
 
@@ -2866,6 +2886,7 @@
   my $elements;
 
   # do that now to have it available for formatting
+  # FIXME set language and documentencoding/encoding_name? If not done already.
   $self->_set_global_multiple_commands(-1);
 
   if ($self->get_conf('USE_NODES')) {
@@ -2990,10 +3011,8 @@
   my $self = shift;
 
   if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}) {
-    foreach my $content_type(['contents', 'Contents'],
-                             ['shortcontents', 'Overview']) {
-      my $cmdname = $content_type->[0];
-      my $type = $content_type->[1];
+    foreach my $cmdname('contents', 'shortcontents') {
+      my $type = $contents_command_element_name{$cmdname};
       if ($self->get_conf($cmdname)) {
         my $default_filename;
         if ($self->get_conf('INLINE_CONTENTS')) {
@@ -3028,7 +3047,7 @@
           }
           $filename = $default_filename if (!defined($filename));
           print STDERR "Add content $element $type: target $target, id $id,\n".
-             "    filename $filename\n";# if ($self->get_conf('DEBUG'));
+             "    filename $filename\n" if ($self->get_conf('DEBUG'));
           $self->{'targets'}->{$element} = {'id' => $id,
                                             'target' => $target,
                                             'misc_filename' => $filename,
@@ -3249,9 +3268,12 @@
   my $self = shift;
   my $external_node = shift;
 
+  my $node_content = [];
+  $node_content = $external_node->{'node_content'}
+    if (defined($external_node->{'node_content'}));
   return $self->_convert({'type' => '_code',
-        'contents' => [{'text' => '('}, $external_node->{'manual_content'},
-                       {'text' => ')'}, $external_node->{'node_content'}]});
+        'contents' => [{'text' => '('}, @{$external_node->{'manual_content'}},
+                       {'text' => ')'}, @$node_content]});
 }
 
 my %valid_types = (
@@ -3273,7 +3295,7 @@
   
   if ($type eq 'href') {
     return $self->_external_node_href($external_node, $filename);
-  } elsif ($type eq 'text') {
+  } elsif ($type eq 'text' or $type eq 'node') {
     return $self->_external_node_text($external_node);
   }
 }
@@ -3374,8 +3396,8 @@
       $command = $element_target->{'extra'}->{'element_command'};
       $target = $self->{'targets'}->{$command} if ($command);
     }
-  } elsif ($self->{'special_elements'}->{$direction}) {
-    $element_target = $self->{'special_elements'}->{$direction};
+  } elsif ($self->special_element($direction)) {
+    $element_target = $self->special_element($direction);
     $command = $element_target;
     if ($type eq 'href') {
       return $self->command_href($element_target, $filename);
@@ -3601,7 +3623,8 @@
 </head>
 
 <body $bodytext>
-$after_body_open";
+$after_body_open
+";
 
   return $result;
 }
@@ -3621,7 +3644,16 @@
 
   if ($special_type eq 'About') {
     my $about = "<p>\n";
+    my $PRE_ABOUT = $self->get_conf('PRE_ABOUT');
+    if (defined($PRE_ABOUT)) {
+      if (ref($PRE_ABOUT) eq 'CODE') {
+        $about .= &$PRE_ABOUT($self, $element);
+      } else {
+        $about .= $PRE_ABOUT;
+      }
+    } else {
     $about .= '  '.&{$self->{'program_string'}}($self) ."\n";
+    }
     $about .= <<EOT;
 </p>
 <p>
@@ -3697,10 +3729,16 @@
       </li>
 EOT
     $about .= '      <li>1.4 ' . $self->convert_tree($self->gdt('Subsection 
One-Four')) . "</li>\n";
+
+    my $AFTER_ABOUT = '';
+    if (defined($self->get_conf('AFTER_ABOUT'))) {
+      $AFTER_ABOUT = $self->get_conf('AFTER_ABOUT');
+    }
     $about .= <<EOT;
     </ul>
   </li>
 </ul>
+$AFTER_ABOUT
 EOT
     return $about;
   } elsif ($special_type eq 'Contents') {
@@ -3817,9 +3855,6 @@
     }
   }
 
-  # FIXME Before that, set multiple commands
-  # FIXME set language and documentencoding/encoding_name
-
   $self->_prepare_index_entries();
 
   $self->set_conf('BODYTEXT', 'lang="' . $self->get_conf('documentlanguage') 
@@ -4160,6 +4195,10 @@
     #  if (defined($root->{'extra'}) and $root->{'extra'}->{'def_command'});
   }
 
+  if (ref($root) ne 'HASH') {
+    cluck "_convert: root not a HASH\n";
+    return '';
+  }
 
   if (($root->{'type'}
         and exists ($self->{'types_conversion'}->{$root->{'type'}})



reply via email to

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