Open erykml opened 2 years ago
Hey @erykml, thanks for the report!
To be clear I expect hyperlinks to only work on supported terminals. To my knowledge, the default macOS terminal and integrated VSCode temrinal do not support hyperlinks. But iTerm2 >3.1 absolutely should (it's what I use).
Regardless of what terminal you use, I am surprised that you are getting that output though. It looks like nbpreview is actually doing what I want it to do, you can see that type of pattern as the expected output in the unit tests. But, I expected your terminal to format it nicely for you. For example, this is what it looks like on my machine when I try to render a link using macOS's default terminal. There is no clickable hyperlink, but I don't get the long path text you do.
So right now:
What happens if you try to render any hyperlink to both of your terminals? One quick way to check this.
% python -m venv .venv
% source .venv/bin/activate
% python -m pip install rich
% python -m rich.markdown --hyperlinks <(echo '[Click me](https://github.com/paw-lu/nbpreview/issues/506)')
This won't fix the hyperlink problem at all, but to make it less of an eyesore for now you can pass --no-hyperlinks
to have nbpreview print out the entire path name, which you can click on in some terminals like VSCode, or --no-files
to keep nbpreview to disable the feature all together. Both of these can be configured more permenantly by setting their respective enrivonmental variables NBPREVIEW_HYPERLINKS=0
or NBPREVIEW_NO_FILES=1
.
Hi @paw-lu!
Thanks for the very fast answer! To answer your questions in order:
Hopefully, this will help with narrowing down the issue! And thanks for the temporary fix :)
Thanks @erykml for helping me out with debugging!
New theory is that it's your pager. Are you using a custom pager (ie not less
) or special commands?
To veriy that this is a pager issue. We can prevent nbpreview by writing to your pager with --no-paging
.
% nbpreview --no-paging notebook.ipynb
If the issue has to do with your pager, then you should get working hyperlinks (on iTerm2 at least).
What do you have set for PAGER
or other environmental variables that affect paging (like LESS
).
% echo $PAGER
% echo $LESS
Like we mentioned above, you can use the --no-paging
to diable nbpreview from outputting to your pager. Or set NBPREVIEW_PAGING=0
for a more permanent config.
Set a pager that can interpret the escape codes given. Does less -r
work for you?
% PAGER='less -r' nbpreview --paging notebook.ipynb
Hi @paw-lu,
No worries, happy to help!
Let me answer in order.
--no-paging
flag works -> the links are clickable and nicely formatted + there is no looping behavior.less
and -R
respectively.PAGER='less -r' nbpreview --paging notebook.ipynb
works as well.So based on those, seems like the pager is indeed at fault. Thanks for helping me out with this issue!
So based on those, seems like the pager is indeed at fault.
Eh, the issue is the pager, but I didn't expect you to have such a standard setup. I suspeceted you might be using some exotic pager, but your setup is what 98% of users will have. It's identical to what I have actually. I was hoping nbpreview would just work on setups like this.
Regardless, to be explictâfor you and future usersâyou can fix this problem permentantly by setting PAGER
in your startupfiles (.bashrc
, .zshrc
, .zshenv
, .bash_profile
, etc).
export PAGER='less -r'
This will also help with other clis as well.
But this is a pretty frustrating first-impression for a standard setup. Let's keep this open for now to see if we can measure how common this is.
Wonder if you have an older version of less
? Kinda grasping at straws.
What happened?
Hi, first of all, great job with the library! Coming back to the issue at hand, the links to HTML outputs (DataFrames) and Images do not work. I have tried the default MacOS terminal, iterm2, and the terminal integrated into VS Code. All of them look like the sample provided in the output field. It happens with all the Notebooks I have (also saved using Jupyter Notebook and not VS Code).
nbpreview version
nbpreview 0.8.1
Output
8;id=410413;file:///var/folders/jg/42cx8xxn6_s1kcdc594gmf_w0000gn/T/tmprg7rbhah.htmlđ Click to view HTML8;;
Notebook
No response
OS
macos
Terminal
terminal/vs code terminal
Python version
Python 3.8.10