Skip to content

Commit 78639c2

Browse files
committed
smoother way to handle sublists.
1 parent 4bfdbd6 commit 78639c2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tests/test_lists.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_nested_list():
1313
l.add_item('li', 'test')
1414
s = List('ol', indent_level=2)
1515
s.add_item('li', 'another one')
16-
l.add_item('li', s, sublist=True)
16+
l.add_item('li', s)
1717
result = l.process()
1818
expect = '\t<ol>\n\t\t<li>test\n\t\t<ol>\n\t\t\t<li>another one</li>\n\t\t</ol></li>\n\t</ol>'
1919
assert result == expect
@@ -31,3 +31,17 @@ def test_nested_list():
3131
result = l.process()
3232
expect = '\t<ol>\n\t\t<li>test\n\t\t<ol>\n\t\t\t<li>another one\n\t\t\t<ul>\n\t\t\t\t<li>point one</li>\n\t\t\t\t<li>point two</li>\n\t\t\t</ul></li>\n\t\t\t<li>moar item</li>\n\t\t</ol></li>\n\t</ol>'
3333
assert result == expect
34+
35+
l = List('ol')
36+
l.add_item('li', 'test')
37+
s1 = List('ol')
38+
s1.add_item('li', 'another one')
39+
s2 = List('ul')
40+
s2.add_item('li', 'point one')
41+
s2.add_item('li', 'point two')
42+
s1.add_item('li', s2)
43+
s1.add_item('li', 'moar item')
44+
l.add_item('li', s1)
45+
result = l.process()
46+
expect = '\t<ol>\n\t\t<li>test\n\t\t<ol>\n\t\t<li>another one\n\t\t<ul>\n\t\t<li>point one</li>\n\t\t<li>point two</li>\n\t</ul></li>\n\t\t<li>moar item</li>\n\t</ol></li>\n\t</ol>'
47+
assert result == expect

textile/objects/list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self, listtype, attributes={}, indent_level=0):
88
self.indent_level = indent_level
99
self.items = []
1010

11-
def add_item(self, tag, content, attributes={}, sublist=False):
11+
def add_item(self, tag, content, attributes={}):
1212
item = ListItem(tag, content, attributes)
1313
if type(content) is List:
1414
# if we are nesting lists, pop off the content of the most-recently

0 commit comments

Comments
 (0)