I was planning on editing the text blob before it's saved to the
database.

So a blob like:
"This is a big blob of text
<code>This is the code part</code>
This is another line"

would be converted to:
"This is a big blob of text
<code>This&nbsp;is&nbsp;the&nbsp;code&nbsp;part</code>
This is another line"

And then called back as <%= @article.body %> in the view.

I thought that was a simple option.

Would hpricot be appropriate here?

I should also add that I plan on having a safe-list of tags, so any
potentially harmful tags like <script> would be removed

Does that clarify at all?

Thanks

On Apr 29, 7:14 pm, Tim <[email protected]> wrote:
> You don't want to fall into the rat hole of parsing HTML with
> regexes.  You need a parsing library like hpricot or similar.
>
> http://wiki.github.com/why/hpricot
>
> good luck!
> Tim
>
> On Apr 29, 11:09 am, Gavin <[email protected]> wrote:
>
> > Hi all
>
> > I'm having a bit of trouble trying to acheive something, maybe someone
> > can help?
>
> > I have a model Article, which has an attribute 'body'
>
> > The body is a text column in which people can add text and HTML.
>
> > I'd like to edit certain properties of some of the HTML tags, for
> > example, converting all spaces inside <code> </code> tags to &nbsp;
>
> > I presume using a reg expression is the best way to achieve this, I'm
> > just not sure of how to word an expression to scan for only characters
> > within the html tags.
>
> > any ideas?
>
> > Ta
>
> > Gavin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to