texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Pl...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Parser.pm Texinfo/Convert/Pl...
Date: Sat, 04 Dec 2010 22:22:27 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/12/04 22:22:27

Modified files:
        tp/Texinfo     : Parser.pm 
        tp/Texinfo/Convert: Plaintext.pm 
        tp/t/results/float: numbering_captions_listoffloats.pl 

Log message:
        Handle @listoffloats.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.161&r2=1.162
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/float/numbering_captions_listoffloats.pl?cvsroot=texinfo&r1=1.2&r2=1.3

Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -b -r1.161 -r1.162
--- Texinfo/Parser.pm   4 Dec 2010 17:59:19 -0000       1.161
+++ Texinfo/Parser.pm   4 Dec 2010 22:22:27 -0000       1.162
@@ -2100,7 +2100,6 @@
         }
       }
     } elsif ($command eq 'listoffloats') {
-      my $empty_listoffloats = 1;
       if (!_parse_float_type($current)) {
         _line_error ($self, sprintf($self->__("address@hidden missing 
argument"), 
            $command), $line_nr);

Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- Texinfo/Convert/Plaintext.pm        4 Dec 2010 17:59:19 -0000       1.24
+++ Texinfo/Convert/Plaintext.pm        4 Dec 2010 22:22:27 -0000       1.25
@@ -466,6 +466,9 @@
   return $result;
 }
 
+my $listoffloat_entry_length = 41;
+my $listoffloat_append = '...';
+
 # on top, the converter object which holds some gloal information
 # 
 # context (for footntes, multitable cells):
@@ -528,7 +531,6 @@
   # 
   # other commands processed:
   # verbatiminclude
-  # insertcopying
   # listoffloats
   # dircategory
   # center
@@ -921,10 +923,69 @@
           }
         }
       } elsif ($root->{'cmdname'} eq 'listoffloats') {
-        if (defined($self->{'parser'})) {
+        if ($root->{'extra'} and $root->{'extra'}->{'type'}
+            and defined($root->{'extra'}->{'type'}->{'normalized'}) 
+            and defined($self->{'parser'})) {
           my $floats = $self->{'parser'}->floats_information();
+          if ($floats and $floats->{$root->{'extra'}->{'type'}->{'normalized'}}
+               and @{$floats->{$root->{'extra'}->{'type'}->{'normalized'}}}) {
+            $result = "* Menu:\n\n";
+            foreach my $float 
(@{$floats->{$root->{'extra'}->{'type'}->{'normalized'}}}) {
+              next if 
(!defined($float->{'extra'}->{'block_command_line_contents'}->[1]));
+              my $float_entry;
+              if (exists ($float->{'number'})) {
+                $float_entry = 
+                 $self->gdt('* {float_type} {float_number}: {float_label}.', 
+                  {'float_type' => $root->{'extra'}->{'type'}->{'content'},
+                   'float_number' => $float->{'number'},
+                   'float_label' => 
$float->{'extra'}->{'block_command_line_contents'}->[1]});
+              } else {
+                $float_entry = $self->gdt('* {float_type}: {float_label}.', 
+                  {'float_type' => $root->{'extra'}->{'type'}->{'content'},
+                   'float_label' => 
$float->{'extra'}->{'block_command_line_contents'}->[1]
+                   });
+              }
+              #print STDERR "$float ".$self->convert_line($float_entry)."\n";
+              my $float_line = $self->convert_line($float_entry);
+              my $line_width 
+                 = Texinfo::Convert::Unicode::string_width($float_line);
+              if ($line_width > $listoffloat_entry_length) {
+                $float_line .= "\n" . ' ' x $listoffloat_entry_length;
+              } else {
+                $float_line .= ' ' x ($listoffloat_entry_length - $line_width);
+              }
+              $line_width = $listoffloat_entry_length;
+              my $caption;
+              if ($float->{'extra'}->{'shortcaption'}) {
+                $caption = $float->{'extra'}->{'shortcaption'};
+              } elsif ($float->{'extra'}->{'caption'}) {
+                $caption = $float->{'extra'}->{'caption'};
+              }
+              if ($caption) {
+                # FIXME should there be some indentation?
+                my $caption_text = $self->convert({'contents' => 
$caption->{'args'}->[0]->{'contents'},
+                            'type' => $caption->{'cmdname'}.'_listoffloats'});
+                while ($caption_text =~ 
s/^\s*(\p{Unicode::EastAsianWidth::InFullwidth}\s*|\S+\s*)//) {
+                  my $new_word = $1;
+                  $new_word =~ s/\n/ /g;
+                  if ((Texinfo::Convert::Unicode::string_width($new_word) +
+                       $line_width) > 
+                           ($self->{'format_context'}->[-1]->{'max'} - 3)) {
+                    $float_line .= $listoffloat_append;
+                    last;
+                  } else {
+                    $float_line .= $new_word;
+                    $line_width += 
+                      Texinfo::Convert::Unicode::string_width($new_word);
+                  }
+                }
+              }
+              $result .= $float_line. "\n";
+            }
+            $result .= "\n";
+            $self->{'empty_lines_count'} = 1;
+          }
         }
-        # FIXME handle listoffloats
       } elsif ($root->{'cmdname'} eq 'sp') {
         if ($root->{'extra'}->{'misc_args'}->[0]) {
           # this useless copy avoids perl changing the type to integer!

Index: t/results/float/numbering_captions_listoffloats.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/float/numbering_captions_listoffloats.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- t/results/float/numbering_captions_listoffloats.pl  4 Dec 2010 00:01:40 
-0000       1.2
+++ t/results/float/numbering_captions_listoffloats.pl  4 Dec 2010 22:22:27 
-0000       1.3
@@ -6821,6 +6821,24 @@
 
    A ref to float without type *note label but no type::.
 
+* Menu:
+
+* Text 1: text with a lot of features.   TeX and someething 
+* Text 1.1: text in chapter.             C Text in chapter 
+* Text 1.2: float with a lot of features and no shortcaption.
+                                         An example of float ...
+* Text 1.3: text in section.             
+* Text 5: unnumbered float.              SC unnumbered float 
+* Text 6: Section within unnumbered float.
+                                         SC Section within ...
+* Text 2.1: Chapter with subsec float.   SC Chapter with subsec 
+* Text 2.2: unnumbered sec float.        SC unnumbered sec float 
+* Text A.1: appendix sec float.          SC appendix sec float 
+
+* Menu:
+
+* the\'ore`me 1.1: theoreme.              C A the\'ore`me 
+
 ';
 
 1;



reply via email to

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