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

Locate URLs in text output and convert them to hyperlinks. #2464

Merged
merged 1 commit into from Oct 31, 2012

Conversation

embray
Copy link
Contributor

@embray embray commented Oct 3, 2012

The subject of this PR came up in a discussion on the Astropy mailing list, in which we were discussing including URLs to help pages in some exception messages. The question came up as to how different terminals handle URLs, and which ones render them as hyperlinks.

The question also came up in the context of IPython Notebook. I knew that Markdown cells already detect and render URLs, but that is not true for the output from normal code cells, so this fixes that. Is there any good reason not to do this? I've tried several cases and this seems to work pretty well.

@Carreau
Copy link
Member

Carreau commented Oct 31, 2012

It seem like a good idea.

Do you have a link to the Astopy ML discussion about that, and any practical case ?
Could this (also) be done by using a _repr_html on the particular object you want to display (it will then also target the qtconsole)

@embray
Copy link
Contributor Author

embray commented Oct 31, 2012

Given that the objects in question are exceptions, I don't think that would work. I could be wrong but I don't think _repr_html will work in tracebacks.

Here's the (somewhat lengthy) discussion in question: https://groups.google.com/d/topic/astropy-dev/mS2dF0D-zkM/discussion

To summarize, the use case is that we want except messages to, in some cases, include URLs to more detailed help text in the online documentation. Many modern terminal emulators commonly in use today do display URLs as clickable hyperlinks. So we figured IPython Notebook ought to do the same.

@embray
Copy link
Contributor Author

embray commented Oct 31, 2012

And as for your comment about qtconsole it should probably also render URLs as hyperlinks, if it doesn't already. But I can't test it right now since I don't have it working on my work machine. Maybe when I get home I can try it on my laptop.

@Carreau
Copy link
Member

Carreau commented Oct 31, 2012

And as for your comment about qtconsole it should probably also render URLs as hyperlinks, if it doesn't already

No, it doesn't autodetect link in text. It could be added too I think.
As for the link, it was just for references.

Traceback can surely be enhanced, but you should look at IPython/core/ultratb.py then.
But I'm not quite familiar with this part of the code.

It would be great to be able to get a Debugger like werkzeug one in the notebook.

Carreau added a commit that referenced this pull request Oct 31, 2012
Locate URLs in notebook text output and convert them to hyperlinks.
@Carreau Carreau merged commit 47593e4 into ipython:master Oct 31, 2012
@embray
Copy link
Contributor Author

embray commented Oct 31, 2012

Thanks--I'll have to see if we can do more with this somewhere in ultratb.py.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Locate URLs in notebook text output and convert them to hyperlinks.
@anonderpling
Copy link

This is actually pretty annoying. I'm not sure if this is a colab "enhancement" or comes directly from colab, but this also links paths...including paths in `backticks`, paths in <pre>preformatted blocks</pre> and other methods. I can add <wbr> in the middle like /<wbr>home/anonderpling/.gitconfig, however that breaks once I put the path in backticks, as it no longer inserts a wordbreak. I can enter a zero-width space to do so, but then the path can no longer be copied and used, as it now contains an invisible character.

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

Successfully merging this pull request may close these issues.

None yet

3 participants