[Po4a-commits] "po4a/lib/Locale/Po4a Text.pm,1.14,1.15"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Mon Mar 31 20:28:48 UTC 2008


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory alioth:/tmp/cvs-serv1217/lib/Locale/Po4a

Modified Files:
	Text.pm 
Log Message:
Added support for the fortunes format in the Text module.


Index: Text.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Text.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Text.pm	8 Aug 2007 12:01:17 -0000	1.14
+++ Text.pm	31 Mar 2008 20:28:45 -0000	1.15
@@ -83,6 +83,15 @@
 
 my $debianchangelog = 0;
 
+=item B<fortunes>
+
+Handle the fortunes format, which separate fortunes with a line which
+consists in '%' or '%%', and use '%%' as the beginning of a comment.
+
+=cut
+
+my $fortunes = 0;
+
 sub initialize {
     my $self = shift;
     my %options = @_;
@@ -96,6 +105,10 @@
     if (defined $options{'debianchangelog'}) {
         $debianchangelog=1;
     }
+
+    if (defined $options{'fortunes'}) {
+        $fortunes=1;
+    }
 }
 
 sub parse {
@@ -124,6 +137,15 @@
             $paragraph="";
             $self->pushline("$line\n");
             $expect_header=1;
+        } elsif ($fortunes and
+                 $line =~ m/^%%?\s*$/) {
+            # Found end of fortune
+            do_paragraph($self,$paragraph,$wrapped_mode);
+            $self->pushline("\n") unless (   $wrapped_mode == 0
+                                          or $paragraph eq "");
+            $paragraph="";
+            $wrapped_mode = 1;
+            $self->pushline("$line\n");
         } elsif ($line =~ /^\s*$/) {
             # Break paragraphs on lines containing only spaces
             do_paragraph($self,$paragraph,$wrapped_mode);
@@ -146,6 +168,8 @@
                 # paragraph
                 $wrapped_mode = 0;
             }
+            $line =~ s/%%(.*)$//;
+# TODO: comments
             $paragraph .= $line."\n";
         }
         # paragraphs starting by a bullet, or numbered
@@ -230,7 +254,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
- Copyright 2005,2007 by Nicolas FRANÇOIS <nicolas.francois at centraliens.net>.
+ Copyright 2005-2008 by Nicolas FRANÇOIS <nicolas.francois at centraliens.net>.
 
 This program is free software; you may redistribute it and/or modify it
 under the terms of GPL (see the COPYING file).




More information about the Po4a-commits mailing list