105 |
|
} # end char while |
106 |
|
} # End String while loop |
107 |
|
undef $filehandle; |
108 |
< |
$self->_printstream(); |
108 |
> |
# make sure we close the last buffer |
109 |
> |
$self->_calltag($self->{textcontext}, $self->{textcontext}, |
110 |
> |
$self->_getstore()); |
111 |
> |
#$self->_printstream(); |
112 |
|
} |
113 |
|
|
114 |
|
# |
149 |
|
|
150 |
|
# ---- In a tag |
151 |
|
if ( $self->{tagcontext}=~/tag/ ) { |
152 |
+ |
$self->{tagbuff}=$self->{tagbuff}.$char; |
153 |
|
if ( ! $self->_quotetest($char) ) { |
154 |
|
if ( ! $self->_labeltest($char) ) { |
155 |
|
if ( $char eq ">") { $self->_closetag(); } |
172 |
|
my $self=shift; |
173 |
|
my $char; |
174 |
|
$char=substr($self->{currentline},$self->{stringpos}++,1); |
175 |
< |
# print "Debug : Fetching character $char\n"; |
175 |
> |
#print "Debug : Fetching character $char\n"; |
176 |
|
|
177 |
|
# Keep a record for any stream processes |
178 |
|
$self->{streamstore}=$self->{streamstore}.$char; |
196 |
|
|
197 |
|
# Do we have an opening or closing tag? |
198 |
|
if ( ($char=$self->_nextchar()) eq "/" ) { #we have a closing tag |
199 |
+ |
$self->{tagbuff}="<".$char; |
200 |
|
$self->{tagcontext}="endtag"; |
201 |
|
} |
202 |
|
else { # an opening tag |
203 |
+ |
$self->{tagbuff}="<"; |
204 |
|
$self->{tagcontext}="starttag"; |
205 |
|
$self->_checkchar($char); |
206 |
|
} |
226 |
|
|
227 |
|
# -- Now make sure the text context is set for calling routines to |
228 |
|
# -- deal with text portions outside of tags |
229 |
< |
if ( $self->{tagcontext} eq "starttag" ) { |
230 |
< |
push @{$self->{textstack}} , $self->{textcontext}; |
231 |
< |
$self->{textcontext}=$self->{tagname}; |
229 |
> |
if ( ($self->{tagcontext} eq "starttag") ) { |
230 |
> |
if ( $self->{tagcontainer}->definescontext($self->{tagname}) ) { |
231 |
> |
push @{$self->{textstack}} , $self->{textcontext}; |
232 |
> |
$self->{textcontext}=$self->{tagname}; |
233 |
> |
} |
234 |
|
} |
235 |
|
else { |
236 |
|
if ( $#{$self->{textstack}} > -1 ) { |
237 |
< |
if ( $self->{textcontext} eq $self->{tagname} ) { |
238 |
< |
$self->{textcontext}=pop @{$self->{textstack}}; |
239 |
< |
} |
237 |
> |
if ( $self->{textcontext} eq $self->{tagname} ) { |
238 |
> |
if ( $self->{tagcontainer}->definescontext($self->{tagname}) ) { |
239 |
> |
# -- watch out for valid tags we ignore in this parse |
240 |
> |
$self->{textcontext}=pop @{$self->{textstack}}; |
241 |
> |
} |
242 |
> |
} |
243 |
|
else { #The tag we are closing is not the last one so |
244 |
|
# we keep our current context. |
245 |
|
$self->_removefromstack($self->{tagname},$self->{textstack}); |
247 |
|
|
248 |
|
} |
249 |
|
else { # more close tags than open ones |
250 |
+ |
if ( $self->{tagcontainer}->definescontext($self->{tagname}) ) { |
251 |
|
print "Warning : Unmatched </...> tag on line ". |
252 |
|
$self->line()."\n"; |
253 |
+ |
} |
254 |
|
} |
255 |
|
} |
256 |
|
} |
388 |
|
|
389 |
|
# Do we have a label name? |
390 |
|
if ( $self->{lastlabel} ne "" ) { |
391 |
< |
$self->{tagvar}{$self->{lastlabel}}=$self->_getstore(); |
391 |
> |
(my $label=$self->{lastlabel})=~tr[A-Z][a-z]; |
392 |
> |
$self->{tagvar}{$label}=$self->_getstore(); |
393 |
|
$self->{lastlabel}=""; |
394 |
|
} |
395 |
|
elsif ( $self->_getstore() ne "") { |
398 |
|
($self->{tagname}=$self->_getstore())=~tr/A-Z/a-z/; |
399 |
|
} |
400 |
|
else { |
401 |
< |
die ">Tag syntax error in $self->{tagname} on line ". |
402 |
< |
$self->line()." of file \n$self->{filename}"; |
401 |
> |
# do not die anymore - breaks non tag documents |
402 |
> |
#die ">Tag syntax error in $self->{tagname} on line ". |
403 |
> |
# $self->line()." of file \n$self->{filename}"; |
404 |
> |
# -- assume that this is plain text |
405 |
> |
$self->{tagcontext}="text"; |
406 |
> |
$self->_resetstore(); |
407 |
> |
$self->_unshiftstore($self->{tagbuff}); |
408 |
> |
$self->{tagbuff}=""; |
409 |
> |
return; |
410 |
|
} |
411 |
|
} |
412 |
|
$self->_resetstore(); |
422 |
|
$self->{stringbuff}=$self->{stringbuff}.$char; |
423 |
|
} |
424 |
|
|
425 |
+ |
sub _unshiftstore() { |
426 |
+ |
my $self=shift; |
427 |
+ |
my $char=shift; |
428 |
+ |
|
429 |
+ |
$self->{stringbuff}=$char.$self->{stringbuff}; |
430 |
+ |
} |
431 |
+ |
|
432 |
|
sub _getstore() { |
433 |
|
my $self=shift; |
434 |
|
|