Sha256: 1f3f62915626252bf6786269fa0a0536d498ca0dfd0df0fa1626f3fc6327e10a
Contents?: true
Size: 685 Bytes
Versions: 1
Compression:
Stored size: 685 Bytes
Contents
class BBCoder attr_reader :raw def self.configure(&block) configuration.instance_eval(&block) end def self.configuration @configuration ||= BBCoder::Configuration.new end def initialize(text) @raw = text.split(/(\[[^\]]+\])/i).select {|string| string.size > 0} end def to_html @html ||= parse end def parse raw.each do |data| case data when /\[\/([^\]]+)\]/ buffer.tags.pop($1) # popping end tag when /\[([^\]]+)\]/ buffer.tags.push($1) # pushing start tag else buffer.push(data) # content end end buffer.join end def buffer @buffer ||= BBCoder::Buffer.new end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bbcoder-0.1.6 | lib/bbcoder/base.rb |