# Red cloth question

**URL:** <https://www.ruby-forum.com/t/red-cloth-question/89570>\
**Category:** Ruby\
**Created:** [January 4, 2006, 9:54pm UTC](https://www.ruby-forum.com/t/red-cloth-question/89570 "2006-01-04T21:54:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_T\_Allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Sean\_T\_Allen](https://www.ruby-forum.com/u/Sean_T_Allen)\
**Post date:** [January 4, 2006, 9:54pm UTC](https://www.ruby-forum.com/t/red-cloth-question/89570/1 "2006-01-04T21:54:58Z")

</div>

can someone point me in the direction of documentation for tweaking red  
cloth?

in particular i want to have it make all hrefs be

thanks for any help.

---

<div class="post-metadata">

**Author:** ![Sean\_T\_Allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Sean\_T\_Allen](https://www.ruby-forum.com/u/Sean_T_Allen)\
**Post date:** [January 5, 2006, 7:29am UTC](https://www.ruby-forum.com/t/red-cloth-question/89570/2 "2006-01-05T07:29:12Z")

</div>

Thanks Ross,

The link, just what i was looking for, the code, a nice extra…

---

<div class="post-metadata">

**Author:** ![Sean\_T\_Allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@Sean\_T\_Allen](https://www.ruby-forum.com/u/Sean_T_Allen)\
**Post date:** [January 5, 2006, 12:05am UTC](https://www.ruby-forum.com/t/red-cloth-question/89570/3 "2006-01-05T00:05:33Z")

</div>

On Wed, 04 Jan 2006 20:53:39 -0000, Sean T Allen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> can someone point me in the direction of documentation for tweaking red  
> cloth?
> 
> in particular i want to have it make all hrefs be

 

If you’re determined to ‘tweak’ RedCloth this seems to work:

 

```
require 'redcloth'

class RedCloth
  def inline_textile_link( text )
    text.gsub!( LINK_RE ) do |m|
      pre,atts,text,title,url,slash,post = $~[1..7]

      url, url_title = check_refs( url )
      title ||= url_title

      atts = pba( atts )
      atts = " href=\"#{ url }#{ slash }\"#{ atts }"
      atts << " title=\"#{ title }\"" if title
      atts = shelve( atts ) if atts

      "#{ pre }<a#{ atts } target=\"_blank\">#{ text }</a>#{ post }"
    end
  end
end

puts RedCloth.new('Read "the friendly

```

 

manual":[http://redcloth.rubyforge.org/](http://redcloth.rubyforge.org/)').to\_html

However, are you sure it’s necessary?

```
rc = RedCloth.new('You "really

```

should…“:[http://c2.com/cgi/wiki?KeepItSimpleStupid](http://c2.com/cgi/wiki?KeepItSimpleStupid)’)  
puts rc.to\_html.gsub(/\<a([^\>]\*)\>/,'\<a\1 target=”\_blank"\>')

Cheers,
