def ensure_not_within_tag_definition(cursor, forward=True):
 (block, offset) = (cursor.block(), cursor.positionInBlock())
 (b, boundary) = next_tag_boundary(block, offset, forward=False)
 if (b is None):
  return False
 if boundary.is_start:
  if forward:
   (block, boundary) = next_tag_boundary(block, offset)
   if (block is not None):
    cursor.setPosition(((block.position() + boundary.offset) + 1))
    return True
  else:
   cursor.setPosition((b.position() + boundary.offset))
   return True
 return False

def ensure_not_within_tag_definition ( cursor , forward = True ) : ( block , offset ) = ( cursor . block ( ) , cursor . positionInBlock ( ) ) ( b , boundary ) = next_tag_boundary ( block , offset , forward = False ) if ( b is None ) : return False if boundary . is_start : if forward : ( block , boundary ) = next_tag_boundary ( block , offset ) if ( block is not None ) : cursor . setPosition ( ( ( block . position ( ) + boundary . offset ) + 1 ) ) return True else : cursor . setPosition ( ( b . position ( ) + boundary . offset ) ) return True return False
ensure the cursor is not inside a tag definition <> .