# Getting HTML attributes, and dropping that HTML tag

**URL:** <https://www.ruby-forum.com/t/getting-html-attributes-and-dropping-that-html-tag/92182>\
**Category:** Ruby\
**Created:** [April 16, 2007, 10:59pm UTC](https://www.ruby-forum.com/t/getting-html-attributes-and-dropping-that-html-tag/92182 "2007-04-16T22:59:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phillip\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7ab992/32.png) [@Phillip\_G](https://www.ruby-forum.com/u/Phillip_G)\
**Post date:** [April 16, 2007, 10:59pm UTC](https://www.ruby-forum.com/t/getting-html-attributes-and-dropping-that-html-tag/92182/1 "2007-04-16T22:59:42Z")

</div>

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