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
|