From 5bc64a45f7b1437bdaafde2728dbcea559e2cede Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Tue, 5 Sep 2006 13:21:03 +0000 Subject: [PATCH] ($FCKdiff, NewFckGetDiff): Deleted again. (NewFckImproveDiff): New. --- modules/fckeditor.pl | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/fckeditor.pl b/modules/fckeditor.pl index 57abae34..a7824a0b 100644 --- a/modules/fckeditor.pl +++ b/modules/fckeditor.pl @@ -16,12 +16,11 @@ # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA, -$ModulesDescription .= '

$Id: fckeditor.pl,v 1.5 2006/09/05 11:54:46 as Exp $

'; +$ModulesDescription .= '

$Id: fckeditor.pl,v 1.6 2006/09/05 13:21:03 as Exp $

'; -use vars qw($FCKeditorHeight $FCKdiff); +use vars qw($FCKeditorHeight); $FCKeditorHeight = 400; # Pixel -$FCKdiff = 1; # 1 = strip HTML tags before running diff push (@MyRules, \&WysiwygRule); @@ -53,14 +52,21 @@ sub WysiwygScript { } } -*OldFckGetDiff = *GetDiff; -*GetDiff = *NewFckGetDiff; +*OldFckImproveDiff = *ImproveDiff; +*ImproveDiff = *NewFckImproveDiff; -sub NewFckGetDiff { - my ($old, $new, $revision) = @_; - if ($FCKdiff) { - $old =~ s/<.*?>//g; - $new =~ s/<.*?>//g; +sub NewFckImproveDiff { + my $old = OldFckImproveDiff(@_); + my $new = ''; + my $protected = 0; + foreach my $str (split(/(|<\/strong>)/, $old)) { + # Don't remove HTML tags affected by changes. + $protected = 1 if $str eq ''; + # strip html tags (and don't get confused with the < and > created + # by diff! + $str =~ s/\<\/?[a-z]+.*?\>//g unless $protected; + $protected = 0 if $str eq ''; + $new .= $str; } - return OldFckGetDiff($old, $new, $revision); + return $new; }