[Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.1,1.2 text-extract2.pl,1.34,1.35
Ambrose Li
acli at users.sourceforge.net
Tue Feb 17 00:46:38 CET 2004
- Previous message: [Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,NONE,1.1 VerboseWarnings.pm,NONE,1.1 text-extract2.pl,1.33,1.34
- Next message: [Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.2,1.3 text-extract2.pl,1.35,1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/koha/koha/misc/translator
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5197
Modified Files:
TmplTokenizer.pm text-extract2.pl
Log Message:
Some functions should not be in the module; these are now removed.
Index: TmplTokenizer.pm
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/TmplTokenizer.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** TmplTokenizer.pm 16 Feb 2004 23:42:57 -0000 1.1
--- TmplTokenizer.pm 16 Feb 2004 23:46:34 -0000 1.2
***************
*** 266,294 ****
###############################################################################
- sub debug_dump (*) { # for testing only
- my($h) = @_;
- print "re_tag_compat is /$re_tag_compat/\n";
- for (;;) {
- my $s = next_token $h;
- last unless defined $s;
- printf "%s\n", ('-' x 79);
- my($kind, $t, $attr) = @$s; # FIXME
- printf "%s:\n", $kind;
- printf "%4dH%s\n", length($t),
- join('', map {/[\0-\37]/? $_: "$_\b$_"} split(//, $t));
- if ($kind eq KIND_TAG && %$attr) {
- printf "Attributes:\n";
- for my $a (keys %$attr) {
- my($key, $val, $val_orig, $order) = @{$attr->{$a}};
- printf "%s = %dH%s -- %s\n", $a, length $val,
- join('', map {/[\0-\37]/? $_: "$_\b$_"} split(//, $val)),
- $val_orig;
- }
- }
- }
- }
-
- ###############################################################################
-
sub trim ($) {
my($s) = @_;
--- 266,269 ----
***************
*** 300,364 ****
###############################################################################
- sub text_extract (*) {
- my($h) = @_;
- my %text = ();
- for (;;) {
- my $s = next_token $h;
- last unless defined $s;
- my($kind, $t, $attr) = @$s; # FIXME
- if ($kind eq KIND_TEXT) {
- $t = trim $t;
- $text{$t} = 1 if $t =~ /\S/s;
- } elsif ($kind eq KIND_TAG && %$attr) {
- # value [tag=input], meta
- my $tag = lc($1) if $t =~ /^<(\S+)/s;
- for my $a ('alt', 'content', 'title', 'value') {
- if ($attr->{$a}) {
- next if $a eq 'content' && $tag ne 'meta';
- next if $a eq 'value' && ($tag ne 'input'
- || (ref $attr->{'type'} && $attr->{'type'}->[1] eq 'hidden')); # FIXME
- my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
- $val = trim $val;
- $text{$val} = 1 if $val =~ /\S/s;
- }
- }
- }
- }
- # Emit all extracted strings.
- # Don't emit pure whitespace, pure numbers, or TMPL_VAR's.
- for my $t (keys %text) {
- printf "%s\n", $t
- unless $t =~ /^(?:\s|\ $re_end_entity|$re_tmpl_var)*$/os || $t =~ /^\d+$/;
- }
- }
-
- ###############################################################################
-
- sub usage ($) {
- my($exitcode) = @_;
- my $h = $exitcode? *STDERR: *STDOUT;
- print $h <<EOF;
- Usage: $0 [OPTIONS]
- Extract strings from HTML file.
-
- --debug-dump-only Do not extract strings; but display scanned tokens
- -f, --file=FILE Extract from the specified FILE
- --pedantic-warnings Issue warnings even for detected problems which
- are likely to be harmless
- --help Display this help and exit
- EOF
- exit($exitcode);
- }
-
- ###############################################################################
-
- sub usage_error (;$) {
- print STDERR "$_[0]\n" if @_;
- print STDERR "Try `$0 --help' for more information.\n";
- exit(-1);
- }
-
- ###############################################################################
-
=head1 FUTURE PLANS
--- 275,278 ----
Index: text-extract2.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/text-extract2.pl,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** text-extract2.pl 16 Feb 2004 23:42:57 -0000 1.34
--- text-extract2.pl 16 Feb 2004 23:46:34 -0000 1.35
***************
*** 51,63 ****
###############################################################################
- sub trim ($) {
- my($s) = @_;
- $s =~ s/^(?:\s|\ $TmplTokenizer::re_end_entity)+//os;
- $s =~ s/(?:\s|\ $TmplTokenizer::re_end_entity)+$//os;
- return $s;
- }
-
- ###############################################################################
-
sub text_extract (*) {
my($h) = @_;
--- 51,54 ----
***************
*** 68,72 ****
my($kind, $t, $attr) = @$s; # FIXME
if ($kind eq TmplTokenizer::KIND_TEXT) {
! $t = trim $t;
$text{$t} = 1 if $t =~ /\S/s;
} elsif ($kind eq TmplTokenizer::KIND_TAG && %$attr) {
--- 59,63 ----
my($kind, $t, $attr) = @$s; # FIXME
if ($kind eq TmplTokenizer::KIND_TEXT) {
! $t = TmplTokenizer::trim $t;
$text{$t} = 1 if $t =~ /\S/s;
} elsif ($kind eq TmplTokenizer::KIND_TAG && %$attr) {
***************
*** 79,83 ****
|| (ref $attr->{'type'} && $attr->{'type'}->[1] eq 'hidden')); # FIXME
my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
! $val = trim $val;
$text{$val} = 1 if $val =~ /\S/s;
}
--- 70,74 ----
|| (ref $attr->{'type'} && $attr->{'type'}->[1] eq 'hidden')); # FIXME
my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
! $val = TmplTokenizer::trim $val;
$text{$val} = 1 if $val =~ /\S/s;
}
- Previous message: [Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,NONE,1.1 VerboseWarnings.pm,NONE,1.1 text-extract2.pl,1.33,1.34
- Next message: [Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.2,1.3 text-extract2.pl,1.35,1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Koha-cvs
mailing list