astanin / python-tabulate

Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate.
https://pypi.org/project/tabulate/
MIT License
2.1k stars 163 forks source link

Escape sequences in OSC8 "link text" don't get detected #273

Open Orochimarufan opened 1 year ago

Orochimarufan commented 1 year ago

Because of how tabulate deals with OSC8 (hyperlink) sequences, it can't deal with any escape sequences in what it considers the "link text". However, that concept doesn't really exist and neither is a link required to end in an empty OSC8;;ST but is also allowed to directly lead into another link. See https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#a-note-on-openingclosing-hyperlinks

I think it should just remove any OSC8;;ST sequences individually. This should also simplify the code a bit since no captures are needed for the text anymore.

For now, one has to work around this by always placing color escape sequences around the OSC8 sequence instead of the other way around. Partially colored links are impossible (unless splitting up the OSC8 sequence into pieces with the same URL and id)