Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support terminal hyperlinks #55

Open
CosmicHorrorDev opened this issue Feb 24, 2025 · 0 comments
Open

Support terminal hyperlinks #55

CosmicHorrorDev opened this issue Feb 24, 2025 · 0 comments

Comments

@CosmicHorrorDev
Copy link
Collaborator

CosmicHorrorDev commented Feb 24, 2025

Lots of terminal emulators have started supporting hyperlinks (link with some deets)

The short of it is summed up by

A hyperlink is opened upon encountering an OSC 8 escape sequence with the target URI. The syntax is

OSC 8 ; params ; URI ST

Following this, all subsequent cells that are painted are hyperlinks to this target. A hyperlink is closed with the same escape sequence, omitting the parameters and the URI but keeping the separators:

OSC 8 ; ; ST

where:

  • OSC (Operating System Command) is usually ESC ]
  • params are optional special parameters for future use that are typically empty
  • URI is a URI-encoded hyperlink
  • ST (String Terminator) is typically ESC \ or sometimes the BEL character

Here's an example link that's included in rustc's output

ESC ] 8 ; ; https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles ESC \ 'dev' profile [unoptimized + debuginfo] ESC ] 8 ; ; ESC \


Implementation-wise I was thinking we could allow customizing the hyperlink HTML output with a user-definable closure that gets the hyperlink's link, escaped text, and a mutable reference to the output HTML with a reasonable default implementation that creates the typical <a href> links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant