chriskuehl / pygments-ansi-color

ANSI color-code highlighting for Pygments
Other
26 stars 4 forks source link

Lack of ANSI hyperlink support (OSC Sequence Support) #24

Open ssbarnea opened 1 year ago

ssbarnea commented 1 year ago

Over the last decade most terminals added support for ANSI-hyperlinks, which is a small extension of ANSI that allows inclusion of links by applications.

A good resource about this can be found https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda which also includes a bit of history and also the good old https://en.wikipedia.org/wiki/ANSI_escape_code#OSC_(Operating_System_Command)_sequences -- thes extensions are also called OSC sequences.

To give some insights (from what I often use):

The biggest problem with pygments-ansi-color is that it does break the rendering by not following the specification for ANSI escape codes. Even if a terminal is unable to process some codes, it should still be able to ignore them, something that is not happening with this library.

I guess that this could be better fixed in two stages, one that would first make it properly ignore the hyperlink codes, and a second one that would keep render them as links.

ssbarnea commented 1 year ago

https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python looks like a useful resors. Sadly I am not sure how to apply to this library. I seen 3 regexes at https://github.com/chriskuehl/pygments-ansi-color/blob/master/pygments_ansi_color/__init__.py#L293 ... maybe few hints could help here.