Highlight (ActionView::Helpers::TextHelper)

I'm using that helper function with a search form to highlight the
typed phrase in the content BUT when my content is HTML, I'll get
replacement where I don't want to.

For instance :

@page.content = "<p><a href='ajaxian.com' title='Ajaxian.com'><img
src='ajax-image.gif' alt='Ajax Image'/>My text containing AJAX</a></p>"

What I get :
highlight (@page.content, 'ajax')

=> <p><a href='<span class="highlight">ajax</span>ian.com' title='<span
class="highlight">Ajax</span>ian.com'><img src='<span
class="highlight">ajax</span>-image.gif' alt='<span
class="highlight">Ajax</span> Image'/>My text containing <span
class="highlight">ajax</span></a></p>

What I want to get :
highlight (@page.content, 'ajax')

=> <p><a href='ajaxian.com' title='Ajaxian.com'><img
src='ajax-image.gif' alt='Ajax Image'/>My text containing <span
class="highlight">ajax</span></a></p>

Don't know much to RegExp, is this possible to do ?

You want to ask this question on the Rails mailing list. This list is for general ruby questions.

ยทยทยท

On Sep 5, 2006, at 1:45 AM, flornet@gmail.com wrote:

I'm using that helper function with a search form to highlight the
typed phrase in the content BUT when my content is HTML, I'll get
replacement where I don't want to.

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com