def _handle_free_link_text(self, punct, tail, this):
        """Handle text in a free ext link, including trailing punctuation."""
        if "(" in this and ")" in punct:
            punct = punct[:-1]  # ')' is not longer valid punctuation
        if this.endswith(punct):
            for i in range(len(this) - 1, 0, -1):
                if this[i - 1] not in punct:
                    break
            else:
                i = 0
            stripped = this[:i]
            if stripped and tail:
                self._emit_text(tail)
                tail = ""
            tail += this[i:]
            this = stripped
        elif tail:
            self._emit_text(tail)
            tail = ""
        self._emit_text(this)
        return punct, tail
def _handle_free_link_text ( self , punct , tail , this ) : if "(" in this and ")" in punct : punct = punct [ : - 1 ] if this . endswith ( punct ) : for i in range ( len ( this ) - 1 , 0 , - 1 ) : if this [ i - 1 ] not in punct : break else : i = 0 stripped = this [ : i ] if stripped and tail : self . _emit_text ( tail ) tail = "" tail += this [ i : ] this = stripped elif tail : self . _emit_text ( tail ) tail = "" self . _emit_text ( this ) return punct , tail
Handle text in a free ext link, including trailing punctuation.