red cloth question

S

Sean T Allen

--------------000907080308080104080304
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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

in particular i want to have it make all hrefs be <a href=""
target="_blank">

thanks for any help.


--------------000907080308080104080304
Content-Type: text/x-vcard; charset=utf-8;
name="sean.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="sean.vcf"

begin:vcard
fn:Sean T. Allen
n:Allen;Sean T.
org:Ardis Marketing Group
adr;dom:;;;New York;NY
email;internet:[email protected]
title:Tech Guru
x-mozilla-html:FALSE
url:http://ardismg.com/
version:2.1
end:vcard


--------------000907080308080104080304--
 
R

Ross Bamford

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

in particular i want to have it make all hrefs be <a href=""
target="_blank">

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/').to_html

However, are you sure it's necessary?

rc = RedCloth.new('You "really
should...":http://c2.com/cgi/wiki?KeepItSimpleStupid')
puts rc.to_html.gsub(/<a([^>]*)>/,'<a\1 target="_blank">')

Cheers,
 
S

Sean T Allen

--------------070806040800030401020806
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Thanks Ross,

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

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

in particular i want to have it make all hrefs be <a href=""
target="_blank">

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/').to_html

However, are you sure it's necessary?

rc = RedCloth.new('You "really
should...":http://c2.com/cgi/wiki?KeepItSimpleStupid')
puts rc.to_html.gsub(/<a([^>]*)>/,'<a\1 target="_blank">')

Cheers,


--------------070806040800030401020806
Content-Type: text/x-vcard; charset=utf-8;
name="sean.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="sean.vcf"

YmVnaW46dmNhcmQNCmZuOlNlYW4gVC4gQWxsZW4NCm46QWxsZW47U2VhbiBULg0Kb3JnOkFy
ZGlzIE1hcmtldGluZyBHcm91cA0KYWRyO2RvbTo7OztOZXcgWW9yaztOWQ0KZW1haWw7aW50
ZXJuZXQ6c2VhbkBhcmRpc21nLmNvbQ0KdGl0bGU6VGVjaCBHdXJ1DQp4LW1vemlsbGEtaHRt
bDpGQUxTRQ0KdXJsOmh0dHA6Ly9hcmRpc21nLmNvbS8NCnZlcnNpb246Mi4xDQplbmQ6dmNh
cmQNCg0K
--------------070806040800030401020806--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top