Class: RbbCode::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/rbbcode/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Parser

Returns a new instance of Parser.



3
4
5
# File 'lib/rbbcode/parser.rb', line 3

def initialize(config = {})
  @config = config
end

Instance Method Details

#parse(str) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rbbcode/parser.rb', line 7

def parse(str)
  str = escape_html_tags(str)
  
  schema = @config[:schema] || RbbCode::Schema.new
  
  tree_maker = @config[:tree_maker] || RbbCode::TreeMaker.new(schema)
  tree = tree_maker.make_tree(str)
  
  html_maker = @config[:html_maker] || RbbCode::HtmlMaker.new
  html_maker.make_html(tree)
end