Sha256: fde1036b3b84b8880cb28ebc696a2439f7346094ac28a97e63760618594da652
Contents?: true
Size: 854 Bytes
Versions: 4
Compression:
Stored size: 854 Bytes
Contents
#!/usr/bin/env ruby require File.expand_path('../helper', __FILE__) class TestExtensions < Test::Unit::TestCase require 'redcloth' # 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) def test_smiley input = %Q{You're so silly! ~:P} str = RedCloth.new(input).to_html(:textile, :refs_smiley) html = %Q{<p>You’re so silly! <img src='/images/emoticons/58_80.png' title=':P' class='smiley' /></p>} assert_equal(html, str) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
BBRedCloth-0.9.0.alpha1 | test/test_extensions.rb |
BBRedCloth-0.8.8 | test/test_extensions.rb |
BBRedCloth-0.8.7 | test/test_extensions.rb |
BBRedCloth-0.8.6 | test/test_extensions.rb |