[Po4a-commits] po4a/lib/Locale/Po4a TeX.pm,1.18,1.19
Nicolas FRAN??OIS
po4a-devel@lists.alioth.debian.org
Tue, 15 Feb 2005 22:11:52 +0000
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv26892/lib/Locale/Po4a
Modified Files:
TeX.pm
Log Message:
Dont break an argument if it contain an empty line (only supported for
mandatory arguments surrounded by { and }).
Index: TeX.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TeX.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- TeX.pm 15 Feb 2005 22:08:25 -0000 1.18
+++ TeX.pm 15 Feb 2005 22:11:50 -0000 1.19
@@ -757,6 +757,23 @@
}
}
+sub is_closed {
+ my $paragraph = shift;
+# FIXME: [ and ] are more difficult to handle, because it is not easy to detect if it introduce an optional argument
+ my $tmp = $paragraph;
+ my $closing = 0;
+ my $opening = 0;
+ while ($tmp =~ /^.*?(?<!\\)(?:\\\\)*\{(.*)$/s) {
+ $opening += 1;
+ $tmp = $1;
+ }
+ $tmp = $paragraph;
+ while ($tmp =~ /^.*?(?<!\\)(?:\\\\)*\}(.*)$/s) {
+ $closing += 1;
+ $tmp = $1;
+ }
+ return $opening eq $closing;
+}
#############################
#### MAIN PARSE FUNCTION ####
#############################
@@ -787,7 +804,9 @@
$line = "$1%";
}
- if ($line =~ /^ *$/) {#FIXME: \s*?
+ my $closed = is_closed($paragraph);
+
+ if ($closed and $line =~ /^ *$/) {#FIXME: \s*?
# An empty line. This indicates the end of the current
# paragraph.
$paragraph =~ s/(?<!\\)%$//; # FIXME: even number of \ ...
@@ -800,7 +819,8 @@
} elsif ($line =~ /^\\begin\{/) {
# break the paragraph at the beginning of a new environment.
$paragraph =~ s/(?<!\\)%$//; # FIXME: even number of \ ...
- if (length($paragraph)) {
+ $closed = is_closed($paragraph);
+ if ($closed and length($paragraph)) {
($t, @env) = translate_buffer($self,$paragraph,@env);
$self->pushline($t);
}