Index: lib/Locale/Po4a/Sgml.pm =================================================================== RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v retrieving revision 1.77 diff -u -r1.77 Sgml.pm --- lib/Locale/Po4a/Sgml.pm 15 Sep 2005 17:28:43 -0000 1.77 +++ lib/Locale/Po4a/Sgml.pm 15 Sep 2005 19:22:42 -0000 @@ -763,6 +763,7 @@ # Some values for the parsing my @open=(); # opened translation container tags my $verb=0; # can we wrap or not + my $verb_last_ref; my $seenfootnote=0; my $indent=0; # indent level my $lastchar = ''; # @@ -868,7 +869,13 @@ if (scalar @open); } - $verb++ if $verbatim{$event->data->name()}; + if ($verbatim{$event->data->name()}) { + $verb++; + # Keep a reference to the line that openned the verbatim + # section. This is needed to check if its data starts on + # the same line. + $verb_last_ref = $ref; + } if ($indent{$event->data->name()}) { # push the indenting space only if not in verb before that tag # push trailing "\n" only if not in verbose afterward @@ -886,6 +893,17 @@ : 'data->name()).'>'); + if ($verb) { + # Tag in a verbatim section. Check if it appeared at + # the same line than the previous data. If not, it + # means that an end of line must be added to the + # buffer. + if ($ref ne $verb_last_ref) { + # FIXME: Does it work if $verb > 1 + $buffer .= "\n"; + $verb_last_ref = $ref; + } + } print STDERR "Seen $tag, level=".(scalar @open).", verb=$verb\n" if ($debug{'tag'}); @@ -934,7 +952,15 @@ $cdata =~ s/{PO4A-amp}/&/g; $cdata =~ s/{PO4A-end}/\]\]>/g; $cdata =~ s/{PO4A-beg-([^\}]+)}/type eq 're') { if ($verb) { + # Check if this line of data appear on the same line + # than the previous tag. If not, append an end of line + # to the buffer. + if ($ref ne $verb_last_ref) { + $buffer .= "\n"; + $verb_last_ref = $ref; + } $buffer .= "\n"; } elsif ($lastchar ne ' ') { $buffer .= " "; @@ -999,8 +1032,8 @@ $para = $self->translate($para,$ref,$type, 'wrap' => ! $verb, 'wrapcol' => (75 - $indent)); - $para =~ s/^\n//s; unless ($verb) { + $para =~ s/^\n//s; my $toadd=" " x ($indent+1); $para =~ s/^/$toadd/mg; }