[Po4a-commits] "po4a/lib/Locale/Po4a TeX.pm,1.70,1.71"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Wed Sep 21 19:44:19 UTC 2005


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

Modified Files:
	TeX.pm 
Log Message:
Implements the +<env> syntax.


Index: TeX.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TeX.pm,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- TeX.pm	21 Sep 2005 19:15:57 -0000	1.70
+++ TeX.pm	21 Sep 2005 19:44:17 -0000	1.71
@@ -74,6 +74,7 @@
              $RE_ESCAPE $ESCAPE
              $no_wrap_environments
              %separated_command
+             %separated_environment
              &generic_command
              &register_generic_command
              &register_generic_environment);
@@ -111,6 +112,7 @@
 #  '-' The command is not separated, unless it appear alone on a paragraph
 #      (e.g. \strong)
 our %separated_command = ();
+our %separated_environment = ();
 
 =item debug
 
@@ -1008,7 +1010,7 @@
         } elsif ($line =~ m/^((?:\{_?\}|\[_?\])*)\s*$/) {
             register_generic_command("$command,$1");
         }
-    } elsif ($line =~ /^environment\s+(\w+)\s+(.*)$/) {
+    } elsif ($line =~ /^environment\s+([+]?\w+)\s+(.*)$/) {
         my $env = $1;
         $line = $2;
         if ($line =~ m/^((?:\{_?\}|\[_?\])*)\s*$/) {
@@ -1308,15 +1310,20 @@
     print "generic_environment($command,$variant,$args,$env)="
         if ($debug{'environments'});
     my ($t, at e)=("",());
+    my $translated = "";
 
     # The first argument (the name of the environment is never translated)
     # For the others, @types and @translated are used.
-    my $translated = "$ESCAPE$command$variant";
+    $translated = "$ESCAPE$command$variant";
     my @targs = @$args;
     my $type = shift @targs;
     my $opt  = shift @targs;
     my $new_env = $opt;
     $translated .= $type.$new_env.$type_end{$type};
+    if (   (not (defined $separated_environment{$new_env}))
+        or $separated_environment{$new_env} ne '+') {
+        # Use the information from %command_parameters to only translate
+        # the needed parameters
     my @arg_types = @{$environment_parameters{$new_env}{'types'}};
     my @arg_translated = @{$environment_parameters{$new_env}{'translated'}};
 
@@ -1350,6 +1357,20 @@
         $translated .= $type.$t.$type_end{$type};
 
     }
+    } else {
+        # Translate the \begin command with all its arguments joined
+        my ($type, $opt);
+        my $buf = $translated;
+        while (@targs) {
+            $type = shift @targs;
+            $opt  = shift @targs;
+            $buf .= $type.$opt.$type_end{$type};
+        }
+        @e = @$env;
+        $translated = $self->translate($buf,$self->{ref},
+                                       @e?$e[-1]:"Plain text",
+                                       "wrap" => 1);
+    }
     @e = (@$env, $new_env);
 
     print "($translated, at e)\n"
@@ -1416,6 +1437,10 @@
     if ($_[0] =~ m/^(.*),((?:\{_?\}|\[_?\])*)$/) {
         my $env = $1;
         my $arg_types = $2;
+        if ($env =~ /^([+])(.*)$/) {
+            $separated_environment{$2} = $1;
+            $env = $2;
+        }
         my @types = ();
         my @translated = ();
         while (    defined $arg_types




More information about the Po4a-commits mailing list