Skip to content

Commit e9efa6f

Browse files
committed
fix #46
1 parent 6a69f25 commit e9efa6f

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

tests/test_github_issues.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ def test_github_issue_45():
138138
expect = '\t<p><a href="https://myabstractwiki.ru/index.php/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0">test</a></p>'
139139
assert result == expect
140140

141+
def test_github_issue_46():
142+
"""Key error on mal-formed numbered lists. CAUTION: both the input and the
143+
ouput are ugly."""
144+
text = '# test\n### test\n## test'
145+
expect = ('\t<ol>\n\t\t<li>test\n\t\t\t<ol>\n\t\t\t\t<li>test</li>'
146+
'\n\t\t\t</ol></li>\n\t\t<ol>\n\t\t\t<li>test</li>'
147+
'\n\t\t</ol></li>\n\t\t</ol>')
148+
result = textile.textile(text)
149+
assert result == expect
150+
141151
def test_github_issue_47():
142152
"""Incorrect wrap pre-formatted value"""
143153
text = '''pre.. word

textile/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,10 @@ def fTextileList(self, match):
348348
# This will only increment the count for list items, not
349349
# definition items
350350
if showitem:
351-
self.olstarts[tl] = self.olstarts[tl] + 1
351+
try:
352+
self.olstarts[tl] = self.olstarts[tl] + 1
353+
except KeyError:
354+
self.olstarts[tl] = 1
352355

353356
nm = re.match("^(?P<nextlistitem>[#\*;:]+)(_|[\d]+)?{0}"
354357
"[ .].*".format(cls_re_s), nextline)

0 commit comments

Comments
 (0)