all repos — h3rald @ 4a30a33ac9439b1fb669e06899e0e1ffed43f3cc

The sources of https://h3rald.com

lib/bbcode_filter.rb

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
require 'rubygems'
begin
require 'bb-ruby' 
rescue Exception
end

class BbcodeFilter < Nanoc3::Filter
	identifier :bbcode

	def run(content, args)
    custom_tags = {
      'Small' => [
        /\[small\](.*?)\[\/small\]/mi,
        '<small>\1</small>',
        'small',
        '[small]...[/small]',
        :small
      ]
    }
    content.gsub("\n", "<br />").bbcode_to_html(custom_tags, false) rescue content
	end

end