Getting HTML attributes, and dropping that HTML tag


#1

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:
This:

Red here

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
http://cynicalryan.110mb.com/
http://clothred.rubyforge.org

Rule of Open-Source Programming #15:

If you like it, let the author know. If you hate it, let the author
know why.