When spellchecking, show the comment correctly formatted, rather than
having all those ugly HTML tags in the way, making the comment difficult to
understand.
Patch by kareila.
diffs (79 lines):
diff -r e95a0115cf00 -r 095f6506596c cgi-bin/LJ/SpellCheck.pm
--- a/cgi-bin/LJ/SpellCheck.pm Wed Jun 02 12:48:56 2010 +0800
+++ b/cgi-bin/LJ/SpellCheck.pm Wed Jun 02 17:50:33 2010 +0800
@@ -57,8 +57,7 @@ sub new {
# function is empty, then there were no misspellings found.
sub check_html {
- my $self = shift;
- my $journal = shift;
+ my ( $self, $journal, $no_ehtml ) = @_;
return "" unless $$journal;
@@ -70,6 +69,13 @@ sub check_html {
my $data;
$data = <$fh> if PERLIO_IS_ENABLED || IO::Select->new( $fh
)->can_read( 10 );
return defined $data ? $data : '';
+ };
+
+ my $ehtml_substr = sub {
+ my ( $a, $b, $c ) = @_;
+ # we can't substr( @_ ) directly, it won't compile
+ my $str = substr( $a, $b, $c );
+ return $no_ehtml ? $str : LJ::ehtml( $str );
};
# header from aspell/ispell
@@ -99,26 +105,29 @@ sub check_html {
$idata =~ s/^& (\S+) (\d+) (\d+): //;
$mscnt++;
my ( $word, $sugcount, $ofs ) = ( $1, $2, $3 );
+ my $e_word = $no_ehtml ? $word : LJ::ehtml( $word );
+ my $e_idata = $no_ehtml ? $idata : LJ::ehtml( $idata );
$ofs -= 1; # because ispell reports "1" for first character
- $output .= LJ::ehtml( substr( $inline, $srcidx, $ofs - $srcidx
) );
- $output .= "<font color=\"$self->{'color'}\">" . LJ::ehtml(
$word ) . "</font>";
+ $output .= $ehtml_substr->( $inline, $srcidx, $ofs - $srcidx );
+ $output .= "<font color=\"$self->{'color'}\">$e_word</font>";
- $footnotes .= "<tr valign=top><td align=right><font
color=$self->{'color'}>" . LJ::ehtml( $word ) .
- " </font></td><td>" . LJ::ehtml( $idata ) .
"</td></tr>";
+ $footnotes .= "<tr valign=top><td align=right><font
color=$self->{'color'}>$e_word" .
+ " </font></td><td>$e_idata</td></tr>";
$srcidx = $ofs + length( $word );
} elsif ($idata =~ /^\# /) {
$other_bad = 1;
$idata =~ /^\# (\S+) (\d+)/;
my ( $word, $ofs ) = ( $1, $2 );
+ my $e_word = $no_ehtml ? $word : LJ::ehtml( $word );
$ofs -= 1; # because ispell reports "1" for first character
- $output .= LJ::ehtml( substr( $inline, $srcidx, $ofs - $srcidx
) );
- $output .= " <font color=\"$self->{'color'}\">" .
LJ::ehtml( $word ) . "</font> ";
+ $output .= $ehtml_substr->( $inline, $srcidx, $ofs - $srcidx );
+ $output .= " <font
color=\"$self->{'color'}\">$e_word</font> ";
$srcidx = $ofs + length( $word );
}
} while ( $idata ne "" );
- $output .= LJ::ehtml( substr( $inline, $srcidx, length( $inline )
- $srcidx ) ) . "<br>\n";
+ $output .= $ehtml_substr->( $inline, $srcidx, length( $inline ) -
$srcidx ) . "<br>\n";
$lineidx++;
}
diff -r e95a0115cf00 -r 095f6506596c cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm Wed Jun 02 12:48:56 2010 +0800
+++ b/cgi-bin/LJ/Talk.pm Wed Jun 02 17:50:33 2010 +0800
@@ -3539,9 +3539,8 @@ sub make_preview {
if (defined($cleanok) && $LJ::SPELLER && $form->{'do_spellcheck'}) {
my $s = new LJ::SpellCheck { 'spellcommand' => $LJ::SPELLER,
'color' => '<?hotcolor?>', };
- $spellcheck_html = $s->check_html(\$event);
- # unescape the <br />s for readability. All other HTML remains
untouched.
- $spellcheck_html =~ s/<br \/>/<br \/>/g;
+ $spellcheck_html = $s->check_html( \$event, 1 );
+ # second arg '1' means don't escape the HTML
}
$ret .= "$BML::ML{'/talkpost_do.bml.preview.subject'} " .
LJ::ehtml($cleansubject) . "<hr />\n";
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog