Sha256: f00a45e459ae320045596e3799e2948344ef73cd1580aa906e95733c9bc3b6eb
Contents?: true
Size: 687 Bytes
Versions: 3
Compression:
Stored size: 687 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bbcoder-1.0.1 | lib/bbcoder/base.rb |
bbcoder-1.0.0 | lib/bbcoder/base.rb |
bbcoder-0.2.0 | lib/bbcoder/base.rb |