@@ -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 )
@@ -672,7 +672,10 @@ def markStartOfLinks(self, text):
672672 balanced = balanced - 1
673673 if re .search (r'\S$' , possibility , flags = re .U ): # pragma: no branch
674674 balanced = balanced + 1
675- possibility = possible_start_quotes .pop ()
675+ try :
676+ possibility = possible_start_quotes .pop ()
677+ except IndexError :
678+ break
676679 else :
677680 # If quotes occur next to each other, we get zero
678681 # length strings. eg. ...""Open the door,
@@ -756,9 +759,9 @@ def fLink(self, m):
756759 $''' .format (cls_re_s , regex_snippets ['space' ]), inner ,
757760 flags = re .X | re .U )
758761
759- atts = m .group ('atts' ) or ''
760- text = m .group ('text' ) or '' or inner
761- title = m .group ('title' ) or ''
762+ atts = ( m and m .group ('atts' ) ) or ''
763+ text = ( m and m .group ('text' )) or inner
764+ title = ( m and m .group ('title' ) ) or ''
762765
763766 pop , tight = '' , ''
764767 counts = { '[' : None , ']' : url .count (']' ), '(' : None , ')' : None }
0 commit comments