texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp/Texinfo Common.pm Structuring.pm Con...


From: Patrice Dumas
Subject: texinfo/tp/Texinfo Common.pm Structuring.pm Con...
Date: Tue, 12 Apr 2011 21:29:07 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/04/12 21:29:06

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

Log message:
        Non split manual have a page too.
        Add filenames to special elements, put them in trees and output them.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.16&r2=1.17

Patches:
Index: Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- Common.pm   7 Apr 2011 23:08:04 -0000       1.31
+++ Common.pm   12 Apr 2011 21:29:06 -0000      1.32
@@ -127,7 +127,7 @@
   'CSS_LINES', 'RENAMED_NODES_REDIRECTIONS', 'RENAMED_NODES_FILE',
   'TEXI2DVI', 'DUMP_TREE', 'MAX_MACRO_CALL_NESTING',
   'PROGRAM_AND_VERSION', 'PROGRAM_HOMEPAGE', 'PROGRAM',
-  'AFTER_BODY_OPEN', 'EXTRA_HEAD', 'LINKS_BUTTONS');
+  'AFTER_BODY_OPEN', 'EXTRA_HEAD', 'LINKS_BUTTONS', 'DO_ABOUT');
 
 my %valid_options;
 foreach my $var (@document_settable_at_commands, @document_global_at_commands,

Index: Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- Structuring.pm      10 Apr 2011 17:43:16 -0000      1.51
+++ Structuring.pm      12 Apr 2011 21:29:06 -0000      1.52
@@ -616,13 +616,20 @@
   my $elements = shift;
   my $split = shift;
 
-  return undef if (!$elements or !$split);
+  return undef if (!$elements);
 
   my $split_level;
   if ($split eq 'chapter') {
     $split_level = 1;
   } elsif ($split eq 'section') {
     $split_level = 2;
+  } elsif (!$split) {
+    my $page = {'type' => 'page'};
+    foreach my $element (@$elements) {
+      push @{$page->{'contents'}}, $element;
+      $element->{'parent'} = $page;
+    }
+    return [$page];
   }
 
   my @pages = ();

Index: Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- Convert/HTML.pm     11 Apr 2011 00:38:44 -0000      1.16
+++ Convert/HTML.pm     12 Apr 2011 21:29:06 -0000      1.17
@@ -228,11 +228,13 @@
                               'Footnotes' => 'fot',
                               'About' => 'abt'
                               },
+  'misc_elements_order'  => ['Footnotes', 'Contents', 'Overview', 'About'],
   'DOCTYPE'              => '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>',
   'BODYTEXT'             => undef,
   'documentlanguage'     => 'en',
   'SHOW_TITLE'           => 1,
   'SHOW_MENU'            => 1,
+  'MONOLITHIC'           => 1,
 # This is the default, mainly for tests; the caller should set them.  These
 # values are in fact what should be set -- for now when TEST is true.
   'PROGRAM_AND_VERSION'  => 'texi2html',
@@ -855,7 +857,7 @@
   return $result;
 }
 
-# the entry point
+# the entry point for _convert
 sub convert_tree($$)
 {
   my $self = shift;
@@ -943,7 +945,7 @@
       }
       $self->{'targets'}->{$root_command} = {'target' => $target, 
                                              'id' => $id,
-                                             'filename' => $filename};
+                                             'node_filename' => $filename};
     }
   }
 
@@ -1058,9 +1060,21 @@
 {
   my $self = shift;
   my $pages = shift;
-  # Ensure that the document is split
+  my $special_pages = shift;
+
+  # Ensure that the document has pages
   return undef if (!defined($pages) or address@hidden);
 
+  my $extension = '';
+  $extension = '.'.$self->get_conf('EXTENSION') 
+            if (defined($self->get_conf('EXTENSION')) 
+                and $self->get_conf('EXTENSION') ne '');
+
+  if (!$self->get_conf('SPLIT')) {
+    my $page = shift @$pages;
+    $page->{'filename'} = $self->{'document_name'}.$extension;
+    $page->{'out_filename'} = $self->get_conf('OUTFILE');
+  } else {
   my $node_top;
   #my $section_top;
   $node_top = $self->{'labels'}->{'Top'} if ($self->{'labels'});
@@ -1096,15 +1110,13 @@
           if ($root_comand->{'cmdname'} 
               and $root_comand->{'cmdname'} eq 'node') {
             $self->_set_page_file($page, 
-                      $self->{'targets'}->{$root_comand}->{'filename'});
+                        $self->{'targets'}->{$root_comand}->{'node_filename'});
             next PAGE;
           }
         }
       }
       my $filename = $self->{'document_name'} . "_$file_nr";
-      $filename .= '.'.$self->get_conf('EXTENSION') 
-          if (defined($self->get_conf('EXTENSION')) 
-              and $self->get_conf('EXTENSION') ne '');
+        $filename .= $extension;
       $self->_set_page_file($page, $filename);
       $file_nr++;
     }
@@ -1124,17 +1136,26 @@
       $file_nr++;
     }
   }
+  }
   # FIXME there add the special element pages
-  if (defined($Texinfo::Config::page_file_name)) {
+  # also set next_page/prev_page for the special element pages
     foreach my $page (@$pages) {
+    if (defined($Texinfo::Config::page_file_name)) {
       # FIXME pass the information that it is associated with @top or @node 
Top?
       my $filename = &$Texinfo::Config::page_file_name($self, $page, 
                                                        $page->{'filename'});
       $self->_set_page_file($page, $filename) if (defined($filename));
     }
+    $self->{'file_counters'}->{$page->{'filename'}}++;
   }
-  foreach my $page (@$pages) {
+  if ($special_pages) {
+    my $previous_page = $pages->[-1];
+    foreach my $page (@$special_pages) {
     $self->{'file_counters'}->{$page->{'filename'}}++;
+      $page->{'prev_page'} = $previous_page;
+      $previous_page->{'next_page'} = $page;
+      $previous_page = $page;
+    }
   }
 }
 
@@ -1153,6 +1174,89 @@
   return $elements;
 }
 
+sub _prepare_special_elements($)
+{
+  my $self = shift;
+  my $elements;
+  my $pages;
+
+  my %do_special;
+  # FIXME do that here or let it to the user?
+  if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}
+      and !$self->get_conf('INLINE_CONTENTS')) {
+    if ($self->get_conf('contents') 
+        and (!$self->get_conf('setcontentsaftertitlepage')
+             or !$self->get_conf('USE_TITLEPAGE_FOR_TITLE'))) {
+      $do_special{'Contents'} = 1;
+    }
+    if ($self->get_conf('shortcontents')
+        and (!$self->get_conf('setshortcontentsaftertitlepage')
+             or !$self->get_conf('USE_TITLEPAGE_FOR_TITLE'))) {
+      $do_special{'Overview'} = 1;
+    }
+  }
+  if ($self->{'extra'}->{'footnote'} 
+      and $self->get_conf('footnotestyle') eq 'separate') {
+    $do_special{'Footnotes'} = 1;
+  }
+  if ((!defined($self->get_conf('DO_ABOUT')) 
+       and $elements and @$elements > 1 
+           and ($self->get_conf('SPLIT') or $self->get_conf('HEADERS')))
+       or ($self->get_conf('DO_ABOUT'))) {
+    $do_special{'About'} = 1;
+  }
+
+  my $extension = '';
+  $extension = $self->get_conf('EXTENSION') 
+    if (defined($self->get_conf('EXTENSION')));
+
+  foreach my $type (@{$self->{'misc_elements_order'}}) {
+    next unless ($do_special{$type});
+
+    my $element = {'type' => 'element',
+                   'extra' => {'special_element' => $type}};
+    $self->{'special_elements'}->{$type} = $element;
+    push @$elements, $element;
+
+    my $id = $self->{'misc_elements_targets'}->{$type};
+    my $target = $id;
+    my $default_filename;
+    if ($self->get_conf('SPLIT') or !$self->get_conf('MONOLITHIC')) {
+      $default_filename = $self->{'document_name'}.
+        $self->{'misc_pages_file_string'}.$extension;
+    } else {
+      $default_filename = $self->{'OUTFILE'};
+    }
+
+    my $filename;
+    if (defined($Texinfo::Config::special_element_target_file_name)) {
+      ($target, $id, $filename) 
+                 = &$Texinfo::Config::special_element_target_file_name(
+                                                            $self,
+                                                            $element,
+                                                            $target, $id,
+                                                            $default_filename);
+    }
+    $filename = $default_filename if (!defined($filename));
+
+    if ($self->get_conf('SPLIT') or !$self->get_conf('MONOLITHIC')
+        or $filename ne $default_filename) {
+      my $page = {'type' => 'page'};
+      push @{$page->{'contents'}}, $element;
+      $page->{'extra'}->{'element'} = $element;
+      $self->{'special_pages'}->{$type} = $page;
+      $element->{'parent'} = $page;
+      $self->_set_page_file($page, $filename);
+      push @$pages, $page;
+    }
+    $self->{'targets'}->{$element} = {'id' => $id,
+                                      'target' => $target,
+                                      'filename' => $filename,
+                                     };
+  }
+  return ($elements, $pages);
+}
+
 sub htmlxref($$)
 {
   my $self = shift;
@@ -1523,6 +1627,7 @@
            or $self->get_conf('OUTFILE') eq '-'
            or $self->get_conf('OUTFILE') eq '')) {
     $self->force_conf('SPLIT', 0);
+    $self->force_conf('MONOLITHIC', 1);
   }
   if ($self->{'SPLIT'}) {
     $self->set_conf('NODE_FILES', 1);
@@ -1541,69 +1646,46 @@
   # This should return undef if called on a tree without node or sections.
   my $elements = $self->_prepare_elements($root);
 
-  # undef if no elements or not split
-  my $pages = Texinfo::Structuring::split_pages($elements, 
+  # undef if no elements
+  my $pages;
+  if ($self->get_conf('OUTFILE') ne '') {
+    $pages = Texinfo::Structuring::split_pages($elements, 
                                                 $self->get_conf('SPLIT'));
+  }
+
   $self->{'pages'} = $pages;
   
-  # determine file names associated with the different pages.
-  $self->_set_page_files($pages);
+  my ($special_elements, $special_pages) = $self->_prepare_special_elements();
+
+  # determine file names associated with the different pages, and setup
+  # the counters for special element pages.
+  $self->_set_page_files($pages, $special_pages);
 
   # do element directions.  FIXME do it here or before?  Here it means that
   # PrevFile and NextFile can be set.
   Texinfo::Structuring::element_directions($self, $elements);
 
-  # FIXME Before that, set multiple commands
-  # FIXME set language and documentencoding/encoding_name
-
-  # TODO handle special elements, footnotes element, contents and shortcontents
-  # elements, titlepage association
-  # TODO Overview, Footnotes, About.  But also Top, Index, First, Last.
-  
-  my %do_special;
-  # FIXME do that here or let it to the user?
-  if ($self->{'structuring'} and $self->{'structuring'}->{'sectioning_root'}
-      and !$self->get_conf('INLINE_CONTENTS')) {
-    if ($self->get_conf('contents') 
-        and (!$self->get_conf('setcontentsaftertitlepage')
-             or !$self->get_conf('USE_TITLEPAGE_FOR_TITLE'))) {
-      $do_special{'Contents'} = 1;
+  # associate the special elements that have no page to the main page.
+  # This may only happen if not split.
+  if ($special_elements) {
+    foreach my $special_element (@$special_elements) {
+      my $previous_element = $pages->[0]->{'contents'}->[-1];
+      if (!defined($special_element->{'parent'})) {
+        $special_element->{'parent'} = $pages->[0];
+        $special_element->{'element_prev'} = $pages->[0]->{'contents'}->[-1];
+        $pages->[0]->{'contents'}->[-1]->{'element_next'} = $special_element;
+        push @{$pages->[0]->{'contents'}}, $special_element;
+      }
     }
   }
 
-  my $extension = '';
-  $extension = $self->get_conf('EXTENSION') 
-    if (defined($self->get_conf('EXTENSION')));
+  # FIXME Before that, set multiple commands
+  # FIXME set language and documentencoding/encoding_name
 
-  foreach my $type (keys (%{$self->{'misc_elements_targets'}})) {
-    next unless ($do_special{$type});
-    my $page = {'type' => 'page'};
-    my $element = {'type' => 'element',
-                   'parent' => $page,
-                   'extra' => {'special_element' => $type}};
-    push @{$page->{'contents'}}, $element;
-    $page->{'extra'}->{'element'} = $element;
-    $self->{'special_pages'}->{$type} = $page;
-    $self->{'special_elements'}->{$type} = $element;
-    my $id = $self->{'misc_elements_targets'}->{$type};
-    my $target = $id;
-    if (defined($Texinfo::Config::sectioning_command_target_name)) {
-      ($target, $id) = &$Texinfo::Config::special_element_target_name(
-                                                            $self,
-                                                            $element,
-                                                            $target, $id);
-    }
-    $self->{'targets'}->{$element} = {'id' => $id,
-                                      'target' => $target,
-                                     };
-    if ($self->get_conf('SPLIT') or !$self->get_conf('MONOLITHIC')) {
-      my $filename = $self->{'document_name'}. 
-                    $self->{'misc_pages_file_string'}.$extension;
-      $self->_set_page_file($page, $filename);
-      # FIXME allow to change filename + set counter
-    }
-  }
-  $self->set_conf('BODYTEXT',  'lang="' . $self->get_conf('documentlanguage') 
. '" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" 
alink="#FF0000"');
+  # TODO Top, Index, First, Last.
+
+  $self->set_conf('BODYTEXT', 'lang="' . $self->get_conf('documentlanguage') 
+   . '" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" 
alink="#FF0000"');
 
   # prepare title
   my $fulltitle;
@@ -1684,7 +1766,7 @@
   my $fh;
   my $output = '';
   if (!$pages) {
-    # not split output
+    # no page
     if ($self->get_conf('OUTFILE') ne '') {
       $fh = $self->Texinfo::Common::open_out ($self->get_conf('OUTFILE'),
                                             $self->{'perl_encoding'});
@@ -1706,7 +1788,7 @@
       $output .= _output_text($self->_convert($root), $fh);
     } 
   } else {
-    # split output
+    # output with pages
     my %files;
     # TODO set page file names $page->{'filename'} (relative) and 
     # $page->{'out_filename'} (absolute)



reply via email to

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