texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp/Texinfo Structuring.pm Convert/HTML.pm


From: Patrice Dumas
Subject: texinfo/tp/Texinfo Structuring.pm Convert/HTML.pm
Date: Sun, 24 Jul 2011 08:52:21 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/07/24 08:52:21

Modified files:
        tp/Texinfo     : Structuring.pm 
        tp/Texinfo/Convert: HTML.pm 

Log message:
        Do a list of sectioning elements.
        Only output a table of contents if there is more than one sectioning
        element.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.113&r2=1.114

Patches:
Index: Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- Structuring.pm      16 Jul 2011 06:37:47 -0000      1.70
+++ Structuring.pm      24 Jul 2011 08:52:21 -0000      1.71
@@ -168,6 +168,7 @@
   my $number_top_level;
 
   my $section_top;
+  my @sections_list;
   
   # holds the current number for all the levels.  It is not possible to use
   # something like the last child index, because of @unnumbered.
@@ -177,6 +178,7 @@
   foreach my $content (@{$root->{'contents'}}) {
     if ($content->{'cmdname'} and $content->{'cmdname'} ne 'node'
         and $content->{'cmdname'} ne 'bye') {
+      push @sections_list, $content;
       if ($content->{'cmdname'} eq 'top') {
         if ($section_top) {
       #    already warned as a unique command.
@@ -315,6 +317,7 @@
     }
   }
   $self->{'structuring'}->{'sectioning_root'} = $sec_root;
+  $self->{'structuring'}->{'sections_list'} = address@hidden;
   return $sec_root;
 }
 
@@ -896,7 +899,7 @@
   return '@'.$command->{'cmdname'}. ' '
        .Texinfo::Convert::Texinfo::convert ({'contents' => $tree})
           if ($tree);
-  return undef;
+  return 'UNDEF @'.$command->{'cmdname'};
 }
 
 # for debugging

Index: Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -b -r1.113 -r1.114
--- Convert/HTML.pm     20 Jul 2011 14:21:51 -0000      1.113
+++ Convert/HTML.pm     24 Jul 2011 08:52:21 -0000      1.114
@@ -521,7 +521,7 @@
 {
   my $self = shift;
   my $type = shift;
-  return $self->{'special_elements'}->{$type};
+  return $self->{'special_elements_types'}->{$type};
 }
 
 sub global_element($$)
@@ -711,10 +711,10 @@
   # delete the tree and formatted results such that they are redone
   # with the new tree when needed.
   foreach my $special_element (keys (%SPECIAL_ELEMENTS_NAME)) {
-    if ($self->{'special_elements'}->{$special_element} and
-        $self->{'targets'}->{$self->{'special_elements'}->{$special_element}}) 
{
+    if ($self->{'special_elements_types'}->{$special_element} and
+        
$self->{'targets'}->{$self->{'special_elements_types'}->{$special_element}}) {
       my $target 
-        = 
$self->{'targets'}->{$self->{'special_elements'}->{$special_element}};
+        = 
$self->{'targets'}->{$self->{'special_elements_types'}->{$special_element}};
       foreach my $key ('text', 'string', 'tree') {
         delete $target->{$key};
       }
@@ -3621,7 +3621,8 @@
   my $result = '';
   $result .= $titlepage_text.$self->get_conf('DEFAULT_RULE')."\n"
     if (defined($titlepage_text));
-  if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}) {
+  if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}
+      and scalar(@{$self->{'structuring'}->{'sections_list'}}) > 1) {
     if ($self->get_conf('setcontentsaftertitlepage')) {
       my $contents_text = $self->_contents_inline_element('contents', undef);
       if ($contents_text ne '') {
@@ -4354,6 +4355,9 @@
   my $page = shift;
   my $filename = shift;
 
+  if (!defined($filename)) {
+    cluck("_set_page_file: filename not defined\n");
+  }
 # FIXME directory should be the file name!
   $page->{'filename'} = $filename;
   if (defined($self->{'destination_directory'})) {
@@ -4405,9 +4409,9 @@
                                                   or defined($root_command));
         return (undef, undef, undef);
       } elsif ($current->{'cmdname'} eq 'footnote' 
-           and $self->{'special_pages'}->{'Footnotes'}) {
+           and $self->{'special_pages_types'}->{'Footnotes'}) {
         # FIXME element and root_command?
-        return ($self->{'special_pages'}->{'Footnotes'});
+        return ($self->{'special_pages_types'}->{'Footnotes'});
       }
       # } elsif (($current->{'cmdname'} eq 'contents' 
       #           or $current->{'cmdname'} eq 'shortcontents'
@@ -4478,11 +4482,16 @@
         # For Top node.
         next if (defined($page->{'filename'}));
         foreach my $element (@{$page->{'contents'}}) {
-          foreach my $root_comand (@{$element->{'contents'}}) {
-            if ($root_comand->{'cmdname'} 
-                and $root_comand->{'cmdname'} eq 'node') {
+          foreach my $root_command (@{$element->{'contents'}}) {
+            if ($root_command->{'cmdname'} 
+                and $root_command->{'cmdname'} eq 'node') {
+              # Hapens for bogus nodes
+              #if (!defined($self->{'targets'}->{$root_command})
+              #    or 
!defined($self->{'targets'}->{$root_command}->{'node_filename'})) {
+              #  print STDERR "BUG: no target/filename($root_command): 
".Texinfo::Structuring::_print_root_command_texi($root_command)."\n";
+              #}
               $self->_set_page_file($page, 
-                   $self->{'targets'}->{$root_comand}->{'node_filename'});
+                   $self->{'targets'}->{$root_command}->{'node_filename'});
               next PAGE;
             }
           }
@@ -4583,6 +4592,12 @@
   #  }
   #}
   $self->_set_root_commands_targets_node_files($elements);
+  foreach my $couple ([$elements, 'elements'], 
+                      [$special_elements, 'special_elements'],
+                      [$special_pages, 'special_pages']) {
+    $self->{$couple->[1]} = $couple->[0]
+      if (defined($couple->[0]));
+  }
   return ($elements, $special_elements, $special_pages);
 }
 
@@ -4594,7 +4609,8 @@
 
   my %do_special;
   # FIXME do that here or let it to the user?
-  if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}) {
+  if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}
+      and scalar(@{$self->{'structuring'}->{'sections_list'}}) > 1) {
     if ($self->get_conf('contents')) {
       if ($self->get_conf('INLINE_CONTENTS') 
          or ($self->get_conf('setcontentsaftertitlepage')
@@ -4637,7 +4653,7 @@
                    'extra' => {'special_element' => $type,
                                }};
     $element->{'extra'}->{'directions'}->{'This'} = $element;
-    $self->{'special_elements'}->{$type} = $element;
+    $self->{'special_elements_types'}->{$type} = $element;
     push @$special_elements, $element;
 
     my $id = $self->{'misc_elements_targets'}->{$type};
@@ -4669,7 +4685,7 @@
       my $page = {'type' => 'page'};
       push @{$page->{'contents'}}, $element;
       $page->{'extra'}->{'element'} = $element;
-      $self->{'special_pages'}->{$type} = $page;
+      $self->{'special_pages_types'}->{$type} = $page;
       $element->{'parent'} = $page;
       $self->_set_page_file($page, $filename);
       print STDERR "NEW page for $type\n" if ($self->get_conf('DEBUG'));
@@ -4690,7 +4706,8 @@
 {
   my $self = shift;
 
-  if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}) {
+  if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}
+      and scalar(@{$self->{'structuring'}->{'sections_list'}}) > 1) {
     foreach my $cmdname ('contents', 'shortcontents') {
       my $type = $contents_command_element_name{$cmdname};
       if ($self->get_conf($cmdname)) {
@@ -4713,7 +4730,7 @@
         if (defined($default_filename)) {
           my $element = {'type' => 'element',
                          'extra' => {'special_element' => $type}};
-          $self->{'special_elements'}->{$type} = $element;
+          $self->{'special_elements_types'}->{$type} = $element;
           my $id = $self->{'misc_elements_targets'}->{$type};
           my $target = $id;
           my $filename;



reply via email to

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