Sha256: 83db7af40b6a7189b372c58c50b2a69c3312d462163b230ff6df05b969202904
Contents?: true
Size: 566 Bytes
Versions: 6
Compression:
Stored size: 566 Bytes
Contents
class Rad::TextUtils::Urls < Rad::TextUtils::Processor # Creates <a> tags for all urls. # IMPORTANT: make sure you've used #urls_to_images method first # if you wanted all images urls to become <img> tags. def process html, env # becouse it finds only one url in such string "http://some_domain.com http://some_domain.com" we need to aply it twice regexp, sub = /(\s|^|\A|\n|\t|\r)(http:\/\/.*?)([,.])?(\s|$|\n|\Z|\t|\r|<)/, '\1<a href="\2">\2</a>\3\4' html = html.gsub regexp, sub html.gsub regexp, sub call_next html, env end end
Version data entries
6 entries across 6 versions & 1 rubygems