[Po4a-commits] po4a/lib/Locale/Po4a TeX.pm,1.31,1.32

Nicolas FRAN??OIS po4a-devel@lists.alioth.debian.org
Sun, 20 Feb 2005 21:20:24 +0000


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv7455/lib/Locale/Po4a

Modified Files:
	TeX.pm 
Log Message:
Split before \begin and after \end. This avoids missing the beginning or
end of an environment.


Index: TeX.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TeX.pm,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- TeX.pm	20 Feb 2005 19:38:23 -0000	1.31
+++ TeX.pm	20 Feb 2005 21:20:22 -0000	1.32
@@ -558,6 +558,30 @@
     my $orig_buffer = $buffer;
     my $t = ""; # a temporary string
 
+    if ($buffer =~ /^\s*$/s) {
+        return ($buffer, @env);
+    }
+    if ($buffer =~ /^(.+?)(\\begin\{.*)$/s) {
+        my ($begin, $end) = ($1, $2);
+        my ($t1, $t2) = ("", "");
+        if (is_closed($begin)) {
+            ($t1, @env) = translate_buffer($self, $begin, @env);
+            ($t2, @env) = translate_buffer($self, $end,   @env);
+
+            return ($t1.$t2, @env);
+        }
+    }
+    if ($buffer =~ /^(.+?)(\\end\{.*)$/s) {
+        my ($begin, $end) = ($1, $2);
+        my ($t1, $t2) = ("", "");
+        if (is_closed($begin)) {
+            ($t1, @env) = translate_buffer($self, $begin, @env);
+            ($t2, @env) = translate_buffer($self, $end,   @env);
+
+            return ($t1.$t2, @env);
+        }
+    }
+
     # translate leading commands.
     do {
         # keep the leading space to put them back after the translation of
@@ -909,16 +933,6 @@
                 $paragraph="";
             }
             $self->pushline($line."\n");
-        } elsif ($line =~ /^\\begin\{/) {
-            # break the paragraph at the beginning of a new environment.
-            $paragraph =~ s/(?<!\\)(?:\\\\)*%$//;
-            $closed = is_closed($paragraph);
-            if ($closed and length($paragraph)) {
-                ($t, @env) = translate_buffer($self,$paragraph,@env);
-                $self->pushline($t);
-                $paragraph = "";
-            }
-            $paragraph .= $line."\n";
         } else {
             # continue the same paragraph
             if ($paragraph =~ /(?<!\\)(?:\\\\)*%$/) {
@@ -1322,10 +1336,6 @@
 =head1 KNOWN BUGS
 
 =over 4
-
-=item environments
-
-Beginning and end of environments can be missed.
 
 =item commands