X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FTTParser.pm;h=4c3a4a0d001e06c03a567bd1b898716828281920;hb=39d2885d1330afe825e1881f5fc8033d459f6006;hp=e088124684d96f12ee68bb9b4ecd4a4da3024e98;hpb=6eb021ab0e113e2b6b897c89475f1eadc7a2c15b;p=koha.git diff --git a/C4/TTParser.pm b/C4/TTParser.pm index e088124684..4c3a4a0d00 100644 --- a/C4/TTParser.pm +++ b/C4/TTParser.pm @@ -1,4 +1,22 @@ #!/usr/bin/env perl + +# Copyright Tamil 2011 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + #simple parser for HTML with Template Toolkit directives. Tokens are put into @tokens and are accesible via next_token and peep_token package C4::TTParser; use base qw(HTML::Parser); @@ -37,9 +55,9 @@ sub peep_token{ sub build_tokens{ my ($self, $filename) = @_; $self->{filename} = $filename; - $self->handler(start => "start", "self, line, tagname, attr, text"); #signature is start( self, linenumber, tagname, hash of attributes, origional text ) - $self->handler(text => "text", "self, line, text, is_cdata"); #signature is text( self, linenumber, origional text, is_cdata ) - $self->handler(end => "end", "self, line, tag, attr, text"); #signature is end( self, linenumber, tagename, origional text ) + $self->handler(start => "start", "self, line, tagname, attr, text"); #signature is start( self, linenumber, tagname, hash of attributes, original text ) + $self->handler(text => "text", "self, line, text, is_cdata"); #signature is text( self, linenumber, original text, is_cdata ) + $self->handler(end => "end", "self, line, tag, attr, text"); #signature is end( self, linenumber, tagename, original text ) $self->handler(declaration => "declaration", "self, line, text, is_cdata"); # declaration $self->handler(comment => "comment", "self, line, text, is_cdata"); # comments # $self->handler(default => "default", "self, line, text, is_cdata"); # anything else @@ -57,7 +75,7 @@ sub text{ my $is_cdata = shift; while($work){ # if there is a template_toolkit tag - if( $work =~ m/\[%.*?\]/ ){ + if( $work =~ m/\[%.*?%\]/ ){ #everything before this tag is text (or possibly CDATA), add a text token to tokens if $` if( $` ){ my $t = C4::TmplToken->new( $`, ($is_cdata? C4::TmplTokenType::CDATA : C4::TmplTokenType::TEXT), $line, $self->{filename} ); @@ -114,7 +132,7 @@ sub start{ my $line = shift; my $tag = shift; my $hash = shift; #hash of attr/value pairs - my $text = shift; #origional text + my $text = shift; #original text my $t = C4::TmplToken->new( $text, C4::TmplTokenType::TAG, $line, $self->{filename}); my %attr; # tags seem to be uses in an 'interesting' way elsewhere..