def detect_keep_boundary(start, end, namespaces):
    """a helper to inspect a link and see if we should keep the link boundary
    """
    result_start, result_end = False, False
    parent_start = start.getparent()
    parent_end = end.getparent()

    if parent_start.tag == "{%s}p" % namespaces['text']:
        # more than one child in the containing paragraph ?
        # we keep the boundary
        result_start = len(parent_start.getchildren()) > 1

    if parent_end.tag == "{%s}p" % namespaces['text']:
        # more than one child in the containing paragraph ?
        # we keep the boundary
        result_end = len(parent_end.getchildren()) > 1

    return result_start, result_end
def detect_keep_boundary ( start , end , namespaces ) : result_start , result_end = False , False parent_start = start . getparent ( ) parent_end = end . getparent ( ) if parent_start . tag == "{%s}p" % namespaces [ 'text' ] : result_start = len ( parent_start . getchildren ( ) ) > 1 if parent_end . tag == "{%s}p" % namespaces [ 'text' ] : result_end = len ( parent_end . getchildren ( ) ) > 1 return result_start , result_end
a helper to inspect a link and see if we should keep the link boundary