Class: RubyBBCode::TagCollection
- Inherits:
-
Array
- Object
- Array
- RubyBBCode::TagCollection
- Defined in:
- lib/ruby-bbcode/tag_collection.rb
Overview
This class holds TagNode instances and helps build them into html when the time comes.
It is really just a simple array, with the addition of the #to_html method
Defined Under Namespace
Classes: HtmlTemplate
Instance Method Summary collapse
-
#to_html(tags) ⇒ Object
This method is vulnerable to stack-level-too-deep scenarios where >=1,200 tags are being parsed.
Instance Method Details
#to_html(tags) ⇒ Object
This method is vulnerable to stack-level-too-deep scenarios where >=1,200 tags are being parsed.
But that scenario can be mitigated by splitting up the tags. bbtree = { :nodes => [900tags, 1000tags] }, the work for that bbtree can be split up into two passes, do the each node one at a time. I’m not coding that though, it’s pointless, just a thought though
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby-bbcode/tag_collection.rb', line 10 def to_html() html_string = "" self.each do |node| if node.type == :tag t = HtmlTemplate.new node t.inlay_between_text! if node.allow_tag_param? and node.param_set? t.inlay_inline_params! elsif node.allow_tag_param? and node.param_not_set? t.remove_unused_tokens! end html_string << t.opening_html # invoke "recursive" call if this node contains child nodes html_string << node.children.to_html() if node.has_children? # FIXME: Don't use recursion, it can lead to stack-level-too-deep errors for large volumes? t.inlay_closing_html! html_string << t.closing_html elsif node.type == :text html_string << node[:text] unless node[:text].nil? end end html_string end |