texinfo-commits
[Top][All Lists]
Advanced

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

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


From: Patrice Dumas
Subject: texinfo/tp texi2any.pl Texinfo/Parser.pm Texinf...
Date: Sun, 17 Apr 2011 23:19:52 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/04/17 23:19:52

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

Log message:
        First pass at title formatting.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.244&r2=1.245
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.26&r2=1.27

Patches:
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- texi2any.pl 17 Apr 2011 07:27:57 -0000      1.34
+++ texi2any.pl 17 Apr 2011 23:19:52 -0000      1.35
@@ -389,6 +389,8 @@
 
 sub _set_variables_texi2html()
 {
+  # FIXME all that are set to 0 could be negated, in order to have the default
+  # (undef) right.
   set_from_cmdline('NO_USE_SETFILENAME', 1);
   set_from_cmdline('USE_SETFILENAME_EXTENSION', 0);
   set_from_cmdline('footnotestyle', 'separate');

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.244
retrieving revision 1.245
diff -u -b -r1.244 -r1.245
--- Texinfo/Parser.pm   17 Apr 2011 06:27:09 -0000      1.244
+++ Texinfo/Parser.pm   17 Apr 2011 23:19:52 -0000      1.245
@@ -896,6 +896,22 @@
   return "$cmd$type : $args $text $contents\n$parent_string";
 }
 
+sub _print_current_keys($)
+{
+  my $current = shift;
+  my $string = _print_current($current);
+  foreach my $key (keys (%$current)) {
+    $string .= "   $key: $current->{$key}\n";
+  }
+  if ($current->{'extra'}) {
+    $string .= "    EXTRA\n";
+    foreach my $key (keys (%{$current->{'extra'}})) {
+      $string .= "    $key: $current->{'extra'}->{$key}\n";
+    }
+  }
+  return $string;
+}
+
 # For debugging
 my @kept_keys = ('contents', 'cmdname', 'type', 'text', 'args');
 my %kept_keys;

Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- Texinfo/Convert/HTML.pm     17 Apr 2011 07:27:12 -0000      1.26
+++ Texinfo/Convert/HTML.pm     17 Apr 2011 23:19:52 -0000      1.27
@@ -283,6 +283,7 @@
   'BODYTEXT'             => undef,
   'documentlanguage'     => 'en',
   'SHOW_TITLE'           => 1,
+  'USE_TITLEPAGE_FOR_TITLE' => 0,
   'SHOW_MENU'            => 1,
   'MONOLITHIC'           => 1,
 # This is the default, mainly for tests; the caller should set them.  These
@@ -819,6 +820,7 @@
 
 $default_types_conversion{'paragraph'} = \&_convert_paragraph_type;
 
+# FIXME this should be very rare since this is caught by _convert_text.
 sub _convert_empty_line_type($$$) {
   my $self = shift;
   my $type = shift;
@@ -828,6 +830,7 @@
 }
 
 $default_types_conversion{'empty_line'} = \&_convert_empty_line_type;
+# in menu
 $default_types_conversion{'after_description_line'} = 
\&_convert_empty_line_type;
 
 sub _convert_bracketed_type($$$$) {
@@ -997,6 +1000,39 @@
 
 $default_types_conversion{'text_root'} = \&_convert_root_text_type;
 
+# Convert titlepage.  Fall back to simpletitle.
+sub default_titlepage($)
+{
+  my $self = shift;
+
+  my $titlepage_text;
+  if ($self->{'extra'}->{'titlepage'}) {
+    $titlepage_text = $self->convert_tree({'contents' 
+               => $self->{'extra'}->{'titlepage'}->{'contents'}});
+  } elsif ($self->{'simpletitle_tree'}) {
+    my $title_text = $self->convert_tree($self->{'simpletitle_tree'});
+    $titlepage_text = &{$self->{'heading_text'}}($self, 'settitle', 
$title_text, 
+                                            0, {'cmdname' => 'settitle',
+                     'contents' => $self->{'simpletitle_tree'}->{'contents'}});
+  }
+  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->get_conf('setcontentsaftertitlepage')) {
+      # FIXME put formatted contents
+      # @{$Texi2HTML::THISDOC{'inline_contents'}->{'contents'}
+      $result .= $self->get_conf('DEFAULT_RULE')."\n";
+    }
+    if ($self->get_conf('setshortcontentsaftertitlepage')) {
+      # FIXME put formatted shortcontents
+      # @{$Texi2HTML::THISDOC{'inline_contents'}->{'shortcontents'}
+      $result .= $self->get_conf('DEFAULT_RULE')."\n";
+    }
+  }
+  return $result;
+}
+
 sub _convert_element_type($$$$)
 {
   my $self = shift;
@@ -1006,14 +1042,23 @@
 
   #print STDERR "GGGGGGGG $command->{'parent'} 
$command->{'parent'}->{'type'}\n";
   my $result = '';
-  $result .= $content;
-  # FIXME titlepage
   if (!$command->{'element_prev'}) {
+    if ($self->get_conf('SHOW_TITLE')) {
+      if ($self->get_conf('USE_TITLEPAGE_FOR_TITLE')) {
+        $result .= &{$self->{'titlepage'}}($self);
+      } elsif ($self->{'simpletitle_tree'}) {
+        my $title_text = $self->convert_tree($self->{'simpletitle_tree'});
+        $result .= &{$self->{'heading_text'}}($self, 'settitle', $title_text, 
+                                            0, {'cmdname' => 'settitle',
+                     'contents' => $self->{'simpletitle_tree'}->{'contents'}});
+      }
+    }
     if (!$command->{'element_next'}) {
-      return $result.$self->get_conf('DEFAULT_RULE')."\n";
+      return $result.$content.$self->get_conf('DEFAULT_RULE')."\n";
     }
   }
-  return $content;
+  $result .= $content;
+  return $result;
 }
 
 $default_types_conversion{'element'} = \&_convert_element_type;
@@ -1121,6 +1166,7 @@
      ['begin_file', \&default_begin_file, $Texinfo::Config::begin_file],
      ['end_file', \&default_end_file, $Texinfo::Config::end_file],
      ['program_string', \&default_program_string, 
$Texinfo::Config::program_string],
+     ['titlepage', \&default_titlepage, $Texinfo::Config::titlepage],
   ) {
     if (defined($formatting_references->[2])) {
       $self->{$formatting_references->[0]} = $formatting_references->[2];
@@ -1481,6 +1527,12 @@
         # FIXME element and root_command?
         return ($self->{'special_pages'}->{'Footnotes'});
       }
+      # } elsif (($current->{'cmdname'} eq 'contents' 
+      #           or $current->{'cmdname'} eq 'shortcontents'
+      #           or $current->{'cmdname'} eq 'summarycontents')
+      #          and !$self->get_conf('INLINE_CONTENTS')) {
+      #   setcontentsaftertitlepage
+      # }
     }
     if ($current->{'parent'}) {
       $current = $current->{'parent'};
@@ -2080,6 +2132,10 @@
   my $program_homepage = $self->get_conf('PROGRAM_HOMEPAGE');
   my $program = $self->get_conf('PROGRAM');
 
+  # FIXME there is one empty line less than in texi2html.  Seems that in 
+  # texi2html the following empty lines are stripped.  Not exactly sure
+  # how, but it seems that some blank lines are removed before first element.
+  # Maybe misc commands are also stripped before.
   my $result = "$doctype
 <html>
 $copying_comment<!-- Created by $program_and_version, $program_homepage -->
@@ -2248,7 +2304,8 @@
       my $command = $self->{'extra'}->{$simpletitle_command};
       next if ($command->{'extra'} 
                and $command->{'extra'}->{'missing_argument'});
-      $self->{'simpletitle_tree'} = {'contents' => $command->{'misc_content'}};
+      $self->{'simpletitle_tree'} = 
+         {'contents' => $command->{'extra'}->{'misc_content'}};
       last;
     }
   }



reply via email to

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