[Po4a-commits] "po4a/lib/Locale/Po4a Man.pm,1.197,1.198"
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Mon Apr 16 18:38:05 UTC 2007
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory alioth:/tmp/cvs-serv22662/lib/Locale/Po4a
Modified Files:
Man.pm
Log Message:
New 'unknown_macros' option to specify the behavior of po4a with unknown
groff macros.
Index: Man.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Man.pm,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -d -r1.197 -r1.198
--- Man.pm 24 Mar 2007 12:04:44 -0000 1.197
+++ Man.pm 16 Apr 2007 18:38:03 -0000 1.198
@@ -226,6 +226,13 @@
I<foo E<lt>.bar baz quxE<gt> quux>, where I<bar> is the command that
should be inlined, and I<baz qux> its arguments.
+=item B<unknown_macros>
+
+This option indicates how po4a should behave when an unknown macro is found.
+By default, po4a fails with a warning.
+It can take the following values: I<failed> (the default value),
+I<untranslated>, I<noarg>, I<translate_joined>, I<translate_each>.
+
=back
=head1 AUTHORING MAN PAGES COMPLIANT WITH PO4A::MAN
@@ -388,6 +395,8 @@
# Indicate if the page uses the mdoc macros
my $mdoc_mode = 0;
+my $unknown_macros = undef;
+
#########################
#### DEBUGGING STUFF ####
#########################
@@ -443,6 +452,7 @@
$self->{options}{'inline'}='';
$self->{options}{'generated'}='';
$self->{options}{'mdoc'}='';
+ $self->{options}{'unknown_macros'}='';
# reset the debug options
%debug = ();
@@ -517,6 +527,23 @@
}
}
}
+ if (defined $options{'unknown_macros'}) {
+ if ($options{'unknown_macros'} eq "failed") {
+ $unknown_macros = undef;
+ } elsif ($options{'unknown_macros'} eq "untranslated") {
+ $unknown_macros = \&untranslated;
+ } elsif ($options{'unknown_macros'} eq "noarg") {
+ $unknown_macros = \&noarg;
+ } elsif ($options{'unknown_macros'} eq "translate_joined") {
+ $unknown_macros = \&translate_joined;
+ } elsif ($options{'unknown_macros'} eq "translate_each") {
+ $unknown_macros = \&translate_each;
+ } else {
+ die wrap_mod("po4a::man", dgettext("po4a",
+ "Invalid 'unknown_macros' value. Must be one of:\n").
+ "failed untranslated noarg translate_joined translate_each\n");
+ }
+ }
}
my @comments = ();
@@ -1239,9 +1266,13 @@
if (defined ($macro{$macro})) {
&{$macro{$macro}}(@args);
} else {
+ if (defined $unknown_macros) {
+ &{$unknown_macros}(@args);
+ } else {
$self->pushline($self->r($line)."\n");
die wrap_ref_mod($ref, "po4a::man", dgettext("po4a",
"Unknown macro '%s'. Remove it from the document, or refer to the Locale::Po4a::Man manpage to see how po4a can handle new macros."), $line);
+ }
}
} elsif ($line =~ /^ +[^. ]/) {
More information about the Po4a-commits
mailing list