-
Notifications
You must be signed in to change notification settings - Fork 2k
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
manpage builder: emit OSC 8 hyperlinks via groff #12108
Conversation
URLs are not rendered in our man pages. Let's tell Sphinx to include links in the output until sphinx-doc/sphinx#12108 is widely available. In particular, this helps the next commit.
Hyperlink URLs are not included in man output, only link titles are. Configuration option `man_show_urls` allows to append the URL but that doesn't always work well; URLs can be truncated by line wrapping. Also, long links can break the flow of reading. Let's distinguish links with the [OSC 8] escape sequence. This makes the terminal render the link title as clickable link if supported. This relies on a feature that was introduced by groff 1.23.0 (2023-07-05), see https://lists.gnu.org/archive/html/groff/2021-10/msg00000.html. Terminals or groff implementations that don't support this feature should ignore it. [OSC 8]: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda.
I'll let you remove the magic attribute and think of a way to do it with the version info. Maybe you can add that in the documentation of the manpage builder (the RST one) where you recommend to check for Sphinx version to know whether it supports or not OSC 8. |
Sorry I forgot to push yesterday. This should work.
I think the info in the changelog makes it obviuos enough |
Yes, that's right actually. |
I'll wait for the checks to finish and we're good ! thank you in advance ! |
URLs are not rendered in our man pages. Let's tell Sphinx to include links in the output until sphinx-doc/sphinx#12108 is widely available. In particular, this helps the next commit.
several problems
therefore docutils 0.21rc1 renders the references in text, this would allow moving long URLs at the end of the paragraph |
@grubert Thank you for your insights ! I'm sorry but I did not understand "long URLS ... not if using OSC8". Do you mean that long URLs are not well-supported even using OSC 8 ?
I assume that you are asking whether they are supported or not, right? @krobelus do you know about that? If not, I would suggest adding OSC 8 sequences only if the URI is a true URL (and not a local reference).
Oh, I did not know about it. I thought that the link would simply be rendered (without being clickable). @krobelus Can you confirm that Sphinx still renders the link as text if OSC 8 is not supported? @krobelus Maybe we should revert this commit and patch it differently (or follow docutils 0.21rc1?) |
on which terminal are you seeing the problems caused by OSC8 anchors? |
Yes but that was already the case before adding OSC8. Only the link title was shown.
How can I create a local reference that has the
Yes, that's what If so, that's not a problem of OSC 8 anchors, although I recognize the problem. There is a configuration knob (
Yeah, I think rendering
as
would be nice and I might use that -- |
I see that docutils used to use For example
Is equivalent to Which is not possible to express with UR/UE I think. So this example renders URLs as ( As for whether And yeah, as it stands Sphinx needs to override |
…oc#12108) A reference like ":ref:`Some other page <some-other-page>`" results in a refuri "#some-other-page". This does not seem useful to readers of the man page. It is especially unhelpful when using a terminals that implements a hint mode for selecting links -- the extra links add noise, making it harder to select the interesting ones. While at it, relax the restriction that "man_show_urls" is limited to mailto/http/ftp URLs; I don't see why other protocols shouldn't be allowed. Follow up to sphinx-doc#12108 I also confirmed that even with docutils 0.21 we do not need to override depart_reference because we already skip reference nodes.
…oc#12108) A reference like ":ref:`Some other page <some-other-page>`" results in a refuri "#some-other-page". This does not seem useful to readers of the man page. It is especially unhelpful when using a terminal that implements a hint mode for selecting links -- the extra links add noise, making it harder to select the interesting ones. Don't emit OSC 8 for those. Also don't emit it for URLs that might be unsafe (see sphinx-doc#12260 (comment)) I don't know one that would be unsafe but I'm sure there are some. OTOH, "man_show_urls" doesn't seem unsafe because it shows the exact URL that will be opened, so enable that for all URLs (except for relative ones). Follow up to sphinx-doc#12108 I also confirmed that even with docutils 0.21 we do not need to override depart_reference because we already skip reference nodes.
URLs are not rendered in our man pages. Let's tell Sphinx to include links in the output until sphinx-doc/sphinx#12108 is widely available.
…oc#12108) A reference like ":ref:`Some other page <some-other-page>`" results in a refuri "#some-other-page". This does not seem useful to readers of the man page. It is especially unhelpful when using a terminal that implements a hint mode for selecting links -- the extra links add noise, making it harder to select the interesting ones. Don't emit OSC 8 for those. Also don't emit it for URLs that might be unsafe (see sphinx-doc#12260 (comment)) I don't know one that would be unsafe but I'm sure there are some. OTOH, "man_show_urls" doesn't seem unsafe because it shows the exact URL that will be opened, so enable that for all URLs (except for relative ones). Follow up to sphinx-doc#12108 I also confirmed that even with docutils 0.21 we do not need to override depart_reference because we already skip reference nodes.
Hyperlink URLs are not included in man output, only link titles are.
Configuration option
man_show_urls
allows to append the URL but thatdoesn't seem to work well; URLs can be truncated by line wrapping.
Also, long links can break the flow of reading.
Let's distinguish links with the OSC 8 escape sequence. This turns
the link title into clickable link if the terminal supports this
feature.
This relies on a feature that was introduced by groff 1.23.0
(2023-07-05), see https://lists.gnu.org/archive/html/groff/2021-10/msg00000.html.