texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp/Texinfo/Convert Plaintext.pm


From: Patrice Dumas
Subject: texinfo/tp/Texinfo/Convert Plaintext.pm
Date: Sat, 05 Feb 2011 20:16:15 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/02/05 20:16:15

Modified files:
        tp/Texinfo/Convert: Plaintext.pm 

Log message:
        Reorganize closing code to have something easier to read.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.67&r2=1.68

Patches:
Index: Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- Plaintext.pm        5 Feb 2011 19:56:12 -0000       1.67
+++ Plaintext.pm        5 Feb 2011 20:16:15 -0000       1.68
@@ -2045,6 +2045,7 @@
         = $self->{'empty_lines_count'};
     }
   }
+  # close paragraphs and preformatted
   if ($paragraph) {
     $result .= $self->_count_added($paragraph->{'container'},
                                    $paragraph->{'container'}->end());
@@ -2054,8 +2055,17 @@
     }
     pop @{$self->{'formatters'}};
     delete $self->{'format_context'}->[-1]->{'counter'};
+  } elsif ($preformatted) {
+    $result .= $self->_count_added($preformatted->{'container'},
+                                   $preformatted->{'container'}->end());
+    $result = $self->ensure_end_of_line($result);
+    pop @{$self->{'formatters'}};
+    # We assume that, upon closing the preformatted we are at the 
+    # beginning of a line.
+    delete $self->{'format_context'}->[-1]->{'counter'};
   }
 
+  # close commands
   if ($root->{'cmdname'}) {
     if ($root->{'cmdname'} eq 'float') {
       if ($self->{'DEBUG'}) {
@@ -2138,40 +2148,30 @@
                     {'author' => $author->{'extra'}->{'misc_content'}}));
       }
     }
+
     if ($advance_paragraph_count_commands{$root->{'cmdname'}}) {
       $self->{'format_context'}->[-1]->{'paragraph_count'}++;
     }
-  }
-  if ($preformatted) {
-    $result .= $self->_count_added($preformatted->{'container'},
-                                   $preformatted->{'container'}->end());
-    $result = $self->ensure_end_of_line($result);
-    pop @{$self->{'formatters'}};
-    # We assume that, upon closing the preformatted we are at the 
-    # beginning of a line.
-    delete $self->{'format_context'}->[-1]->{'counter'};
-  }
 
-  if ($root->{'cmdname'}) {
+    # close the contexts and register the cells
     if ($preformatted_context_commands{$root->{'cmdname'}}) {
       my $old_context = pop @{$self->{'context'}};
       die if (!$preformatted_context_commands{$old_context});
-    }
-    elsif ($flush_commands{$root->{'cmdname'}}) {
+    } elsif ($flush_commands{$root->{'cmdname'}}) {
       my $old_context = pop @{$self->{'context'}};
       die if (! $flush_commands{$old_context});
     }
-  }
 
-  pop @{$self->{'format_context'}} 
-    if ($root->{'cmdname'} and $format_context_commands{$root->{'cmdname'}}
-        or $cell);
-  if ($cell) {
+    if ($format_context_commands{$root->{'cmdname'}}) {
+      pop @{$self->{'format_context'}};
+    } elsif ($cell) {
+      pop @{$self->{'format_context'}};
     push @{$self->{'format_context'}->[-1]->{'row'}}, $result;
     my $cell_counts = pop @{$self->{'count_context'}};
     push @{$self->{'format_context'}->[-1]->{'row_counts'}}, $cell_counts;
     $result = '';
   }
+  }
 
   return $result;
 }



reply via email to

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