Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
Since handling unknown tags properly (87c44cc) there is no need anymore to treat them in TagSifter
  • Loading branch information
veger committed May 27, 2019
1 parent 87c44cc commit b09430e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lib/ruby-bbcode/tag_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def to_bbcode(tags)
# 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
def to_code(tags, template)
html_string = ''
output_string = ''
each do |node|
if node.type == :tag
t = template.new node
Expand All @@ -30,20 +30,20 @@ def to_code(tags, template)
t.remove_unused_tokens!
end

html_string << t.opening_part
output_string << t.opening_part

# invoke "recursive" call if this node contains child nodes
html_string << node.children.to_code(tags, template) if node.has_children? # FIXME: Don't use recursion, it can lead to stack-level-too-deep errors for large volumes?
output_string << node.children.to_code(tags, template) if node.has_children? # FIXME: Don't use recursion, it can lead to stack-level-too-deep errors for large volumes?

t.inlay_closing_part!

html_string << t.closing_part
output_string << t.closing_part
elsif node.type == :text
html_string << template.convert_text(node)
output_string << template.convert_text(node)
end
end

html_string
output_string
end
end
end
5 changes: 1 addition & 4 deletions lib/ruby-bbcode/tag_sifter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ def process_text
@text.scan(/#{regex_string}/ix) do |tag_info|
@ti = TagInfo.new(tag_info, @dictionary)

# if the tag isn't in the @dictionary list, then treat it as text
@ti.handle_tag_as_text if @ti.element_is_tag? && !@ti.tag_in_dictionary?

validate_element

case @ti.type
Expand Down Expand Up @@ -138,7 +135,7 @@ def get_formatted_element_params
# Get 'between tag' for tag
def get_formatted_between
between = @ti[:text]
# perform special formatting for cenrtain tags
# perform special formatting for certain tags
between = match_url_id(between, @bbtree.current_node.definition[:url_matches]) if @bbtree.current_node.definition[:url_matches]
between
end
Expand Down

0 comments on commit b09430e

Please sign in to comment.