So, I took Cory's advice: I made a box and bound it to the story_new and
story_update hooks. It works like a charm.
For those interested, here is the box contents:
my ($hookname, $sid) = @ARGS;
# We've got the story id fed in from the hook
# Get the introtext and the bodytext from the database
my $q_sid = $S->dbh->quote($sid);
my ($rv, $sth) = $S->db_select({
WHAT => 'introtext,bodytext',
FROM => 'stories',
WHERE => qq\|sid = $q_sid\|
});
my $story_data = $sth->fetchrow_hashref;
$sth->finish;
my $introtext = $story_data->{introtext};
my $bodytext = $story_data->{bodytext};
# Do a find-replace on the nbsp's
$introtext =~ s/ / /gi;
$bodytext =~ s/ / /gi;
# Put introtext and bodytext back into the database
my $q_introtext = $S->dbh->quote($introtext);
my $q_bodytext = $S->dbh->quote($bodytext);
($rv, $sth) = $S->db_update({
WHAT => 'stories',
SET => qq\|introtext=$q_introtext,bodytext=$q_bodytext\|,
WHERE => qq\|sid = $q_sid\|
});
$sth->finish;
Cory R. King wrote:
> Howdy Super G,
>
> Double Space Forever! I've learned to double space my sentances back in
> junior high and there is no way I could break the habit now :-)
>
> Seriously though? You would probably have to edit the three functions
> in the source code that handle incoming text: plaintext, autoformat &
> the regular HTML. I'd imagine it would be a simple regex you'd have to
> insert in each one. Something like
>
> # clean up double spaces in HTML
> $content =~ s/ / /gi;
>
> The other "fix" I can think of is creating a scoop hook after story &
> comment posts. You can get the hook to call a box that cleans up the
> HTML in the comment/story to your liking. I'm almost positive that the
> hook will pass in the Story ID or Comment ID when it calls your box
> code. A hook/box is probably not the most elegant fix, it probably the
> easiest way to implement your own HTML filter without touching the
> source code.
>
> Or you can just give us guys who are set in their ways a break ;-)
>
> Let me know if you get something working!
>
> --
> Cory R. King
> Vice President - XLAN, Inc.
>
> Super G wrote:
>> I've been running a Scoop site for about nine months now (and reading
>> Scoop sites for a lot longer than that), and there's something bugging
>> me that I imagine would be quite easy to fix.
>>
>> Many people who learned to type in the typewriter era put two spaces
>> between a period and the start of the next sentence. If this is done
>> in an HTML document, the user agent only displays a single space,
>> conforming with modern typing conventions. However, Scoop seems to
>> have a quirk where it inserts a non-breaking space (nbsp) character in
>> place of the second space. This phenomenon can cause some ugliness,
>> especially when a line starts with the nbsp character, giving a ragged
>> appearance on the left margin.
>>
>> Is there some kind of patch that can be applied to address this
>> problem? Or is there some kind of Scoop box that I can include on my
>> site to filter out the nbsp characters?
>>
>> Thanks,
>> Super G
>> _______________________________________________
>> Scoop-help mailing list
>> Scoop-help at lists.kuro5hin.org
>> http://lists.kuro5hin.org/mailman/listinfo/scoop-help
>>
>