Forum: Ruby Getting HTML attributes, and dropping that HTML tag

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Phillip G. (Guest)
on 2007-04-17 00:59
(Received via mailing list)
I'm stumped a bit, at the current problem in ClothRed development:

Since Textile supports HTML-attributes, I have to implement them
somehow. The suggestion to look at Hpricot was neat, but it doesn't do
what I need (at least, I can't find it).

Let me give an example:
<p id="big-red">Red here</p>
Has to become:
p(#big-red). Red here

So, I'd need a way of: Finding a given attribute, extract it's contents,
place it inside the Textile-markup, and get rid of the HTML tag.

I've been digging through Google and Hpricot's documentation, but
haven't found anything, that does what I want.

My guess is: I need a Regexp, but I have no clue how to match unknown
contents, while discarding known content..

Does anyone have ideas? Or a hint where I should look?

Phillip "CynicalRyan" Gawlowski

Rule of Open-Source Programming #15:

If you like it, let the author know. If you hate it, let the author
know why.
This topic is locked and can not be replied to.