Sha256: 1c48a2e6961de2f395178f5140a511d4962f62aae8f65de2c373e1972338ba83
Contents?: true
Size: 776 Bytes
Versions: 65
Compression:
Stored size: 776 Bytes
Contents
require File.dirname(__FILE__) + '/spec_helper' # http://www.ralree.info/2006/9/13/extending-redcloth module RedClothSmileyExtension def refs_smiley(text) text.gsub!(/(\s)~(:P|:D|:O|:o|:S|:\||;\)|:'\(|:\)|:\()/) do |m| bef,ma = $~[1..2] filename = "/images/emoticons/"+(ma.unpack("c*").join('_'))+".png" "#{bef}<img src='#{filename}' title='#{ma}' class='smiley' />" end end end RedCloth.send(:include, RedClothSmileyExtension) describe RedClothSmileyExtension do it "should include the extension" do input = %Q{You're so silly! ~:P} html = %Q{<p>You’re so silly! <img src='/images/emoticons/58_80.png' title=':P' class='smiley' /></p>} RedCloth.new(input).to_html(:textile, :refs_smiley).should == html end end
Version data entries
65 entries across 65 versions & 8 rubygems