[Po4a-commits] "po4a/lib/Locale/Po4a Sgml.pm,1.80,1.81"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Sun Oct 30 14:29:45 UTC 2005


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

Modified Files:
	Sgml.pm 
Log Message:
Do not translate the leading and trailing spaces.
Restore them only in the case of verbatim blocks.


Index: Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- Sgml.pm	28 Oct 2005 16:55:17 -0000	1.80
+++ Sgml.pm	30 Oct 2005 14:29:42 -0000	1.81
@@ -1023,16 +1023,34 @@
 		
     return unless defined($para) && length($para);
 
+    if (($para =~ m/^\s*$/s) and (not $verb)) {
+	# In non-verbatim environments, a paragraph with only spaces is
+	# like an empty paragraph
+	return;
+    }
+
     # unprotect &entities;
     $para =~ s/{PO4A-amp}/&/g;
     # remove the name"\|\|" nsgmls added as attributes
     $para =~ s/ name=\"\\\|\\\|\"//g;    
     $para =~ s/ moreinfo=\"none\"//g;
 
+    # Extract the leading and trailing spaces. They will be restored only
+    # in verbatim environments.
+    my ($leading_spaces, $trailing_spaces) = ("", "");
+    if ($para =~ m/^(\s*)(.*?)(\s*)$/s) {
+	$leading_spaces = $1;
+	$para = $2;
+	$trailing_spaces = $3;
+    }
+
     $para = $self->translate($para,$ref,$type,
 			     'wrap' => ! $verb,
 			     'wrapcol' => (75 - $indent));
-    unless ($verb) {
+
+    if ($verb) {
+	$para = $leading_spaces.$para.$trailing_spaces;
+    } else {
 	$para =~ s/^\s+//s;
 	my $toadd=" " x ($indent+1);
 	$para =~ s/^/$toadd/mg;




More information about the Po4a-commits mailing list