[Tutor] Highlighting Searched-for text
Rick Pasotto
rickp@telocity.com
Mon Oct 28 17:36:02 2002
On Mon, Oct 28, 2002 at 05:06:25PM -0500, Allen Schmidt wrote:
> Ok, that sorta works...
>
> I forgot to mention that the keywords field is coming in from the form
> defined as 'tokens' so that it is a list as it gets to Python.
>
> This is what I did with your code below in a Python script in Zope:
> colour="#FF0000"
>
>
> start = '<font colour="%s">' % colour
> end = '</font>'
> if keywords:
> for words in keywords:
> return adtext.replace(words, start+words+end)
> else:
> return adtext
>
>
> If the adtext is "This is a fish dish day." and the keyword is "is", this is
> what I get:
>
> Th<font colour="#FF0000">i</font>s <font colour="#FF0000">i</font>s a f<font
> colour="#FF0000">i</font>sh d<font colour="#FF0000">i</font>sh day.
You really ought to surround the keyword with
<span id=color1>keyword</span>
and then have a style sheet that sets the color1 id to whatever you
want.
--
"Of all the sexual aberrations, perhaps the most peculiar is chastity."
-- Remy de Gourmont
Rick Pasotto rickp@telocity.com http://www.niof.net