tl;dr
here's coming from markdown
LINK = ["\033]8;;", "\033]8;;\033\\"]
re.sub(r"\[([^\]]+)\]\(([^\)]+)\)", process_links, line)
def process_links(match):
description = match.group(1)
url = match.group(2)
return f'{LINK[0]}{url}\033\\{UNDERLINE[0]}{description}{UNDERLINE[1]}{LINK[1]}'