RE: [PHP] highlight keywords issue
| From: | Timothy Hitchens \(HiTCHO\) | Date: | Sun, 12 Jan 2003 13:28:05 +0000 |
| Subject: | RE: [PHP] highlight keywords issue | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131331@lists.php.net to get a copy of this message | ||
You will need to break apart the entire document then process each area
inside of the
tags and to be very careful for nested tags.
The simplest way around I have found to do with is to add to tags that
have been processed
with attributes that are ignored by the browser renderer eg... <a
href="/page.html" done="yes">PHP</a>
as you can see the <a href has been processed because I have added in a
extra attribute then continue
to process the entire page from my preg matches.
Nested tags are going to be your biggest issue.
Timothy Hitchens (HiTCHO)
Open Platform Consulting
e-mail: tim@hitcho.com.au
> -----Original Message-----
> From: Hatem Ben [mailto:reflex_news@yahoo.fr]
> Sent: Sunday, 12 January 2003 7:24 PM
> To: PHP List
> Subject: [PHP] highlight keywords issue
>
>
> Heya all,
>
> I'm trying to highlight search keywords in a string,
> everything work expect when this keyword is inside a tag like this :
>
> keyword (php) :
>
> <a href="?go=php">php</a>
>
> <img src="php.gif" border=0 alt="php.net">
>
> will be highlighted to :
>
> <a href="?go=<b style="color: black; background-color:
> #ffff66">php</b>"><b
> style="color: black; background-color: #ffff66">php</b></a>
>
> <img src="<b style="color: black; background-color:
> #ffff66">php</b>.gif" border=0 alt="<b style="color: black;
> background-color: #ffff66">php</b>.net">
>
> I have tryed to separate text from html, then highlight it
> then join html/text again, but this will be very long and not
> really usefull !
>
> I'm using preg_replace :
>
> preg_replace('|\b('.quotemeta($keyword).')\b|iU', '<b
> style="color: black;
> background-color: #ffff66">\\1</b>', $content);
>
> Any help to fix that ?
>
> Thanks;
> Hatem
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>