milkbone57 22 years ago
parent
commit
0ff6affed2
  1. 75
      plugins/Tk-GUI/Tk/BrowseEdit.pm

75
plugins/Tk-GUI/Tk/BrowseEdit.pm

@ -202,53 +202,54 @@ sub to_html @@ -202,53 +202,54 @@ sub to_html
$end ||= 'end';
my ($res, $temp);
my $pos = '1.0';
my $chars = 0;
my ($curtag, $prevtag) = ("", "");
my %all_tags;
my $pos = '0.0';
my $chars = 0;
my ($curtag, $prevtag) = ("", "");
my %all_tags;
while($self->{text}->index($pos) != $self->{text}->index('end'))
while($self->{text}->index($pos) != $self->{text}->index('end'))
{
%all_tags = ();
$all_tags{$_} = $_ for $self->{text}->tagNames($pos);
delete $all_tags{'sel'};
delete $all_tags{'elide'};
delete $all_tags{''};
%all_tags = ();
$all_tags{$_} = $_ for $self->{text}->tagNames($pos);
delete $all_tags{'sel'};
delete $all_tags{'elide'};
delete $all_tags{''};
if(scalar(keys %all_tags) == 0 && $prevtag eq "")
{
$pos = $self->{text}->index('0.0 + ' . ++$chars . " chars");
$res .= $self->{text}->get($pos);
$prevtag = "";
next;
}
if(scalar(keys %all_tags) == 0 && $prevtag eq "")
{
$res .= $self->{text}->get($pos);
$pos = $self->{text}->index('0.0 + ' . ++$chars . " chars");
$prevtag = "";
next;
}
$curtag = (keys %all_tags)[0] || "";
$curtag = (keys %all_tags)[0] || "";
if($prevtag =~ /$curtag/)
{
# tag added
($temp = $prevtag) =~ s/$curtag//;
$res .= end_tag($temp);
}
elsif($curtag =~ /$prevtag/)
{
# tag removed
($temp = $curtag) =~ s/$prevtag//;
$res .= $temp;
}
if($prevtag =~ /$curtag/)
{
# tag added
($temp = $prevtag) =~ s/$curtag//;
$res .= end_tag($temp);
}
elsif($curtag =~ /$prevtag/)
{
# tag removed
($temp = $curtag) =~ s/$prevtag//;
$res .= $temp;
}
$prevtag = $curtag;
$prevtag = $curtag;
$res .= $self->{text}->get($pos);
$pos = $self->{text}->index('0.0 + ' . ++$chars . " chars");
}
$res .= $self->{text}->get($pos);
$pos = $self->{text}->index('0.0 + ' . ++$chars . " chars");
}
my $chr = chr(255);
$res =~ s/$chr//g;
return $res;
my $chr = chr(255);
$res =~ s/$chr//g;
return $res;
}
sub end_tag
{
my ($tag) = @_;

Loading…
Cancel
Save