Skip to content

Commit 6a69f25

Browse files
committed
fix the remaining failures???
1 parent ccedec8 commit 6a69f25

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

textile/core.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ def parse(self, text, rel=None, sanitize=False):
277277
# a newline, replace it with a new style break tag and a newline.
278278
text = re.sub(r'<br( /)?>(?!\n)', '<br />\n', text)
279279

280+
text = text.rstrip('\n')
281+
280282
return text
281283

282284
def table(self, text):
@@ -449,7 +451,7 @@ def block(self, text):
449451
# if we had a previous extended tag but not this time, close up
450452
# the tag
451453
if ext and out:
452-
content = out[-2]
454+
content = encode_html(out[-2], quotes=True)
453455
content = generate_tag(block.inner_tag, content,
454456
block.inner_atts)
455457
content = generate_tag(block.outer_tag, content,
@@ -476,7 +478,10 @@ def block(self, text):
476478
# previous extension to the front
477479
if ext and out:
478480
line = '{0}{1}'.format(out.pop(), line)
479-
if not ext or line[0].strip():
481+
# the logic in the if statement below is a bit confusing in
482+
# php-textile. I'm still not sure I understand what the php
483+
# code is doing.
484+
if not ext and not line[0] == ' ':
480485
block = Block(self, tag, atts, ext, cite, line)
481486
if block.tag == 'p' and not has_raw_text(block.content):
482487
line = block.content
@@ -491,10 +496,7 @@ def block(self, text):
491496
line = line.replace('<br>', '<br />')
492497

493498
if ext and not match:
494-
try:
495-
last_item = out.pop()
496-
except IndexError:
497-
last_item = ''
499+
last_item = out.pop()
498500
out.append('{0}{1}'.format(last_item, line))
499501
elif not block.eat:
500502
out.append(line)

0 commit comments

Comments
 (0)