Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit 5e42a18

Browse files
committed
Just grab parent tag from list instead of creating node from parsed tags
Fixes #30
1 parent 8424611 commit 5e42a18

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/ruby-bbcode/bbtree.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def escalate_bbtree(element)
4646

4747
# Step down the bbtree a notch because we've reached a closing tag
4848
def retrogress_bbtree
49-
# print @tags_list[-1].inspect
5049
if @tags_list[-1].definition[:self_closable]
5150
# It is possible that the next (self_closable) tag is on the next line
5251
# Remove newline of current tag and parent tag as they are (probably) not intented as an actual newline here but as tag separator
@@ -58,8 +57,7 @@ def retrogress_bbtree
5857
# The parsed data manifests in @bbtree.current_node.children << TagNode.new(element) which I think is more confusing than needed
5958

6059
if within_open_tag?
61-
# Set the current node to be the node we've just parsed over which is infact within another node??...
62-
@current_node = TagNode.new(self.nodes.last)
60+
@current_node = @tags_list[-1]
6361
else # If we're still at the root of the BBTree or have returned back to the root via encountring closing tags...
6462
@current_node = TagNode.new({:nodes => self.nodes}) # Note: just passing in self works too...
6563
end

test/ruby_bbcode_html_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def test_unordered_list
5555

5656
def test_list_common_syntax
5757
assert_equal '<ul><li>item 1</li><li>item 2</li></ul>', '[list][*]item 1[*]item 2[/list]'.bbcode_to_html
58+
assert_equal '<ul><li><strong>item 1</strong> test</li><li>item 2</li></ul>', "[list]\n[*][b]item 1[/b] test[*]item 2[/list]".bbcode_to_html
5859
end
5960

6061
def test_newline_list_common_syntax

0 commit comments

Comments
 (0)