Skip to content

Commit 10f49ca

Browse files
Fix exception on ###.. block
1 parent 11397f2 commit 10f49ca

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

tests/test_block.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,10 @@ def test_blockcode_in_README():
6262
with open('tests/fixtures/README.txt') as f:
6363
expect = ''.join(f.readlines())
6464
assert result == expect
65+
66+
def test_blockcode_comment():
67+
input = '###.. block comment\nanother line\n\np. New line'
68+
expect = '\t<p>New line</p>'
69+
t = textile.Textile()
70+
result = t.parse(input)
71+
assert result == expect

textile/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def block(self, text):
465465
else:
466466
# if we're inside an extended block, add the text from the
467467
# previous extension to the front
468-
if ext:
468+
if ext and out:
469469
line = '{0}\n\n{1}'.format(out.pop(), line)
470470
whitespace = ' \t\n\r\f\v'
471471
if ext or not line[0] in whitespace:
@@ -494,7 +494,7 @@ def block(self, text):
494494
cite = ''
495495
graf = ''
496496

497-
if ext:
497+
if ext and out:
498498
out.append(generate_tag(block.outer_tag, out.pop(),
499499
block.outer_atts))
500500
return '\n\n'.join(out)

0 commit comments

Comments
 (0)