koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.1,1.2 text-extra


From: Ambrose Li
Subject: [Koha-cvs] CVS: koha/misc/translator TmplTokenizer.pm,1.1,1.2 text-extract2.pl,1.34,1.35
Date: Mon, 16 Feb 2004 15:46:38 -0800

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|\&nbsp$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|\&nbsp$TmplTokenizer::re_end_entity)+//os;
-     $s =~ s/(?:\s|\&nbsp$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;
                }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]