Skip to content

Commit

Permalink
Cleanup whitespaces across the scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Golubev <[email protected]>
  • Loading branch information
Fat-Zer authored and mquinson committed Jan 28, 2025
1 parent 5d16870 commit a132ab5
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 127 deletions.
164 changes: 82 additions & 82 deletions lib/Locale/Po4a/AsciiDoc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,19 @@ sub translate {
my ( $self, $str, $ref, $type ) = @_;
my (%options) = @_;
if ( $options{'wrap'} == 1 ) {
if ($str =~ / \+\n/) {
$options{'wrap'} = 0;
$str =~ s/([^+])\n/$1 /g;
$str =~ s/ \+\n/\n/g;
$str = $self->SUPER::translate( $str, $ref, $type, %options);
$str =~ s/\n/ +\n/g;
$options{'wrap'} = 1;
} else {
if ( $self->{options}{'cleanspaces'} == 1 ) {
$str =~ s/[ \n]+/ /g;
}
$str = $self->SUPER::translate( $str, $ref, $type, %options);
}
if ($str =~ / \+\n/) {
$options{'wrap'} = 0;
$str =~ s/([^+])\n/$1 /g;
$str =~ s/ \+\n/\n/g;
$str = $self->SUPER::translate( $str, $ref, $type, %options);
$str =~ s/\n/ +\n/g;
$options{'wrap'} = 1;
} else {
if ( $self->{options}{'cleanspaces'} == 1 ) {
$str =~ s/[ \n]+/ /g;
}
$str = $self->SUPER::translate( $str, $ref, $type, %options);
}
} else {
$str = $self->SUPER::translate( $str, $ref, $type, %options );
}
Expand Down Expand Up @@ -592,8 +592,8 @@ sub parse {
do_paragraph( $self, $paragraph, $wrapped_mode );
$wrapped_mode = 0;
$paragraph = "";
$self->pushline( $titlelevel1 . $titlespaces);
$title = $self->translate_indexterms($title);
$self->pushline( $titlelevel1 . $titlespaces);
$title = $self->translate_indexterms($title);
my $t = $self->translate(
$title,
$self->{ref},
Expand Down Expand Up @@ -699,19 +699,19 @@ sub parse {
{
# Found BlockId
do_paragraph( $self, $paragraph, $wrapped_mode );
my $block_id = $1;
$paragraph = "";
my $block_id = $1;
$paragraph = "";
$wrapped_mode = 1;
if ($block_id =~ m/^([^,]+),(.+)$/) {
# Found BlockId with a xlabel
my $xlabel = $2;
$block_id = $1;
$self->pushline( "[[$block_id," );
do_paragraph( $self, $xlabel, 0);
$self->pushline( "]]\n" );
} else {
$self->pushline( $line . "\n" );
}
if ($block_id =~ m/^([^,]+),(.+)$/) {
# Found BlockId with a xlabel
my $xlabel = $2;
$block_id = $1;
$self->pushline( "[[$block_id," );
do_paragraph( $self, $xlabel, 0);
$self->pushline( "]]\n" );
} else {
$self->pushline( $line . "\n" );
}
undef $self->{bullet};
undef $self->{indent};
} elsif ( not defined $self->{verbatim}
Expand Down Expand Up @@ -820,18 +820,18 @@ sub parse {
my $attrname = $1;
my $attrsep = $2;
my $attrvalue = $3;
my $linebreak = "";
my $linebreak = "";
while ( $attrvalue =~ s/ ([\\+])$//s ) {
$linebreak = $1;
# add a carriage return at the end of attrvalue if there is none
$attrvalue .= "\n" if $attrvalue !~ m/\n$/;
$linebreak = $1;
# add a carriage return at the end of attrvalue if there is none
$attrvalue .= "\n" if $attrvalue !~ m/\n$/;
( $line, $ref ) = $self->shiftline();
$ref =~ m/^(.*):[0-9]+$/;
$line =~ s/^\s+|\s+$//;
print STDERR "appending attribute with $line" if $debug{parse};
print STDERR "appending attribute with $line" if $debug{parse};
$attrvalue .= $line;
}
print STDERR "attr definition: $attrvalue\n" if $debug{parse};
print STDERR "attr definition: $attrvalue\n" if $debug{parse};
# Found an Attribute entry
do_paragraph( $self, $paragraph, $wrapped_mode );
$paragraph = "";
Expand All @@ -846,10 +846,10 @@ sub parse {
"comment" => join( "\n", @comments ),
"wrap" => 1
);
$t =~ s/\n/ \\\n/g;
$t =~ s/\n/ \\\n/g;
$self->pushline(":$attrname$attrsep$t\n");
} else {
$attrvalue =~ s/\n/ $linebreak\n/g;
$attrvalue =~ s/\n/ $linebreak\n/g;
$self->pushline(":$attrname$attrsep$attrvalue\n");
}
@comments = ();
Expand Down Expand Up @@ -887,7 +887,7 @@ sub parse {
@comments = ();
}
} elsif ( not defined $self->{verbatim}
and ($paragraph =~ m/^\s*$/)
and ( $paragraph =~ m/^\s*$/ )
and ( $line !~ m/^\.\./ )
and ( $line =~ m/^\.(\S.*)$/ ) )
{
Expand Down Expand Up @@ -928,9 +928,9 @@ sub parse {
$paragraph = $text . "\n";
$self->{indent} = "";
$self->{bullet} = $bullet;
} elsif ( not defined $self->{verbatim}
and ( $line eq " +") ) {
$paragraph .= $line . "\n";
} elsif ( not defined $self->{verbatim}
and ( $line eq " +") ) {
$paragraph .= $line . "\n";
} elsif ( ( $line =~ /^\s*$/ ) and ( !defined( $self->{type} ) or ( $self->{type} ne "Table" ) ) ) {

# When not in table, empty lines or lines containing only spaces do break paragraphs
Expand Down Expand Up @@ -1070,19 +1070,19 @@ sub parse {

if ( ( $paragraph ne "" && $self->{bullet} && length( $self->{indent} || "" ) == 0 ) )
{
if ( ( !$self->{options}{'nolinting'} ) && ($paragraph !~ m/ \+\n/ ) ) {
# Second line of an item block is not indented. It is unindented
# (and allowed) additional text or a new list item.
warn wrap_mod(
"$ref",
dgettext(
"po4a",
"It seems that you are adding unindented content to an item. "
. "The standard allows this, but you may still want to change your document "
. "to use indented text to provide better visual clues to writers."
)
);
}
if ( ( !$self->{options}{'nolinting'} ) && ($paragraph !~ m/ \+\n/ ) ) {
# Second line of an item block is not indented. It is unindented
# (and allowed) additional text or a new list item.
warn wrap_mod(
"$ref",
dgettext(
"po4a",
"It seems that you are adding unindented content to an item. "
. "The standard allows this, but you may still want to change your document "
. "to use indented text to provide better visual clues to writers."
)
);
}
} else {
undef $self->{bullet};
undef $self->{indent};
Expand Down Expand Up @@ -1182,7 +1182,7 @@ sub do_paragraph {
if ( defined $self->{bullet} ) {
my $bullet = $self->{bullet};
my $indent1 = $self->{indent};
$self->pushline($indent1 . $bullet);
$self->pushline($indent1 . $bullet);
}
$paragraph = $self->translate_indexterms($paragraph);

Expand Down Expand Up @@ -1223,35 +1223,35 @@ sub translate_in_regex {
# but that's consistant with the specification.
my ($self, $paragraph, $pattern) = @_;
if ( my @indexes = ($paragraph =~ m/$pattern/g ) ) {
for my $index (@indexes) {
my @terms = ();
while (
$index =~ m/\G(
"(?:[^"\\])+" # quoted term
| (?:[^,\\])+ # unquoted term
)(,\s*+)?/gx
)
{
my $term = $1;
if ( $term =~ /^"(.*)"$/ ) {
push @terms, '"' . ($self->translate(
$1,
$self->{ref},
"Index entry",
"wrap" => 1,
"wrapcol" => 0)) . '"';
} else {
push @terms, $self->translate(
$term,
$self->{ref},
"Index entry",
"wrap" => 1,
"wrapcol" => 0);
}
}
$self->pushline("(((" . join (",", @terms) . ")))");

}
for my $index (@indexes) {
my @terms = ();
while (
$index =~ m/\G(
"(?:[^"\\])+" # quoted term
| (?:[^,\\])+ # unquoted term
)(,\s*+)?/gx
)
{
my $term = $1;
if ( $term =~ /^"(.*)"$/ ) {
push @terms, '"' . ($self->translate(
$1,
$self->{ref},
"Index entry",
"wrap" => 1,
"wrapcol" => 0)) . '"';
} else {
push @terms, $self->translate(
$term,
$self->{ref},
"Index entry",
"wrap" => 1,
"wrapcol" => 0);
}
}
$self->pushline("(((" . join (",", @terms) . ")))");

}
}
$paragraph =~ s/$pattern\n?//g;
return $paragraph;
Expand Down
22 changes: 11 additions & 11 deletions lib/Locale/Po4a/Org.pm
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,17 @@ Locale::Po4a::Org - convert Org documents from/to PO files.
=head1 SYNOPSIS
[type:org] /path/to/master.org \
$lang:/path/to/translation.$lang.org \
opt:" \
--option skip_keywords=' \
include \
export_file_name \
link' \
--option skip_properties=' \
copying \
NOBLOCKING \
ORDERED'"
[type:org] /path/to/master.org \
$lang:/path/to/translation.$lang.org \
opt:" \
--option skip_keywords=' \
include \
export_file_name \
link' \
--option skip_properties=' \
copying \
NOBLOCKING \
ORDERED'"
=head1 DESCRIPTION
Expand Down
22 changes: 11 additions & 11 deletions po4a
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ sub get_options {
"package-version" => undef,
"srcdir" => undef,
"destdir" => undef,
"target-lang" => [],
"target-lang" => [],
"calldir" => cwd()
);
Getopt::Long::config( 'bundling', 'no_getopt_compat', 'no_auto_abbrev' );
Expand Down Expand Up @@ -826,7 +826,7 @@ sub get_options {
'msgmerge-opt=s' => \$msgmerge_opt,
'srcdir=s' => \$opts{"srcdir"},
'destdir=s' => \$opts{"destdir"},
'target-lang=s' => \@{ $opts{"target-lang"} }
'target-lang=s' => \@{ $opts{"target-lang"} }
) or pod2usage();

$opts{"verbose"} = scalar @verbose;
Expand Down Expand Up @@ -1060,13 +1060,13 @@ my (%add_filename); # Global addendum_files: '$lang'=>array of '$path'
sub check_target_langs {
my ($nb, $line) = @_;
if ( scalar @target_langs ) {
# check that all languages are in the list of destination languages are in the list of languages
foreach my $lang (@target_langs) {
die wrap_ref_mod( "$config_file:$nb", "", gettext("Specified destination language '%s' not found in the list of languages."), $lang )
unless grep { $_ eq $lang } @langs;
}
$line = "";
@langs = @target_langs;
# check that all languages are in the list of destination languages are in the list of languages
foreach my $lang (@target_langs) {
die wrap_ref_mod( "$config_file:$nb", "", gettext("Specified destination language '%s' not found in the list of languages."), $lang )
unless grep { $_ eq $lang } @langs;
}
$line = "";
@langs = @target_langs;
}
return $line;
}
Expand Down Expand Up @@ -1209,7 +1209,7 @@ while (<CONFIG>) {
if (@langs);
@langs = map { $_ } @split_args; # deep copy

$line = check_target_langs($nb, $line);
$line = check_target_langs($nb, $line);

} elsif ( $cmd eq "po_directory" ) {
die wrap_ref_mod( "$config_file:$nb", "", gettext("The list of languages cannot be set twice.") )
Expand Down Expand Up @@ -1337,7 +1337,7 @@ while (<CONFIG>) {
gettext("Please create an empty file with the 'pot' extension (e.g. 'myproject.pot').") );
}

$line = check_target_langs($nb, $line);
$line = check_target_langs($nb, $line);

} elsif ( $cmd =~ m/type: *(.*)/ ) {

Expand Down
4 changes: 2 additions & 2 deletions scripts/msgsearch
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ $output = '-';

Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
GetOptions(
'input|i=s' => \$input,
'output|o=s' => \$output,
'input|i=s' => \$input,
'output|o=s' => \$output,
'help|h' => \$help,
'verbose|v' => \@verbose,
'version|V' => \&show_version
Expand Down
42 changes: 21 additions & 21 deletions scripts/po4a-display-pod
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ PO=""
OPTIONS=""

usage () {
echo "Usage : $(basename $0) -m POD_FILE -p PO_FILE [-o PO4A_OPT]"
echo "Usage : $(basename $0) -m POD_FILE -p PO_FILE [-o PO4A_OPT]"
}

while getopts m:p:o:h option; do
case $option in
m)
MASTER=$OPTARG
;;
p)
PO=$OPTARG
;;
o)
OPTIONS="$OPTIONS $OPTARG"
;;
h)
usage
exit 0
;;
[?])
usage 1>&2
exit 1
;;
case $option in
m)
MASTER=$OPTARG
;;
p)
PO=$OPTARG
;;
o)
OPTIONS="$OPTIONS $OPTARG"
;;
h)
usage
exit 0
;;
[?])
usage 1>&2
exit 1
;;
esac
done

Expand All @@ -58,6 +58,6 @@ fi
#SECTION=$(basename $MASTER .pod | sed -e 's/.*\.//')

po4a-translate -f pod -m $MASTER -p $PO -L UTF-8 -k 0 $OPTIONS \
| pod2man -r '' -c TRANSLATED -n $MASTER --utf8 \
| man -l -
| pod2man -r '' -c TRANSLATED -n $MASTER --utf8 \
| man -l -

0 comments on commit a132ab5

Please sign in to comment.