Sha256: 018dca8e99f8e9cba007821600553a5e5eae1c141df1c17280053e803825de55

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require 'bbcoder/base'
require 'bbcoder/configuration'
require 'bbcoder/tag'
require 'bbcoder/buffer'
require 'bbcoder/buffer_tags'
require 'bbcoder/string'

BBCoder.configure do
  tag :p
  tag :b, :as => :strong
  tag :i, :as => :em
  tag :u
  tag :s, :as => :strike
  tag :del
  tag :ins
  tag :ol
  tag :ul
  tag :li, :parents => [:ol, :ul]
  tag :dl
  tag :dt, :parents => [:dl]
  tag :dd, :parents => [:dl]

  tag :quote do
    <<-EOS
<fieldset>
<legend>#{meta} says</legend>
  <blockquote>
    #{content}
  </blockquote>
</fieldset>
    EOS
  end

  tag :code do
    <<-EOS
<div class="bbcode-code #{meta}">
  <pre>#{content}</pre>
</div>
    EOS
  end

  tag :spoiler do
    <<-EOS
<fieldset class="bbcode-spoiler">
  <legend>Spoiler</legend>
  <div>#{content}</div>
</fieldset>
    EOS
  end

  tag :url do
    if meta.nil? || meta.empty?
      %(<a href="#{content}">#{content}</a>)
    else
      %(<a href="#{meta}">#{content}</a>)
    end
  end

  tag :img, :match => /^.*(png|bmp|jpg|gif)$/ do
    %(<a href="#{content}"><img src="#{content}" /></a>)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bbcoder-0.1.3 lib/bbcoder.rb
bbcoder-0.1.2 lib/bbcoder.rb
bbcoder-0.1.1 lib/bbcoder.rb
bbcoder-0.1.0 lib/bbcoder.rb