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&#8217;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

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/RedCloth-4.3.3/spec/extension_spec.rb
RedCloth-4.3.3 spec/extension_spec.rb
gv-RedCloth-4.3.2 spec/extension_spec.rb
RedCloth-4.3.2 spec/extension_spec.rb
RedCloth-4.3.1 spec/extension_spec.rb
RedCloth-4.3.0 spec/extension_spec.rb
parity-RedCloth-4.2.13 spec/extension_spec.rb
parity-RedCloth-4.2.12 spec/extension_spec.rb
parity-RedCloth-4.2.11 spec/extension_spec.rb
parity-RedCloth-4.2.10 spec/extension_spec.rb
parity-RedCloth-4.2.9 spec/extension_spec.rb
YSRedCloth-4.2.18 spec/extension_spec.rb
assplecake-RedCloth-4.2.10 spec/extension_spec.rb
YSRedCloth-4.2.17 spec/extension_spec.rb
YSRedCloth-4.2.16 spec/extension_spec.rb
gv-RedCloth-4.2.9 spec/extension_spec.rb
YSRedCloth-4.2.15 spec/extension_spec.rb
YSRedCloth-4.2.14 spec/extension_spec.rb
YSRedCloth-4.2.13 spec/extension_spec.rb
YSRedCloth-4.2.12 spec/extension_spec.rb