-
Notifications
You must be signed in to change notification settings - Fork 149
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
Wrapped links are invalid #36
Comments
I have created an issue within the glow repository after doing some additional testing. It appears to be a bug within glow, not this program. The solution I have proposed here and in the glow issue should resolve things. If glow takes too long to fix this, it could potentially be implemented as a hacky fix within this program until glow fixes it on their end. |
This is definitely an issue with glow. I don't think I want to implement a fix here, it's outside the scope of this project. I'll keep up with the issue in glow. If you can find a maintainable solution for this repo, I'd be more than happy to look at a PR, though. Thank you for bringing this to my attention. |
Upon closer inspection, this doesn't seem to be an issue with glow, you should be able to configure this. You can invoke glow with the -s flag and provide a custom style definition in json, see this page for details. I think using the prefix, suffix, and block_prefix/block_suffix, you should be able to wrap links in this escape sequence. I'm sceptical about whether we should use that as a default, though, since not many terminal emulators seem to actually support this escape sequence. Here's the relevant PR for alacritty, for example. If you're interested, you could see if you manage to create a style definition for this, it shouldn't be that hard, afterwards, we could think about trying to detect that ability, but I don't want to add much complexity to this script, so I can't promise anything about merging such functionality. |
Isn't this related to the terminal's capability to create links automatically from text? I cannot reproduce this on |
That's what I was talking about. You can reproduce their issue using kitty though. |
I say it is an issue with glow, as I believe it should do that for you. When I write
As to this comment, I don't believe so, no. In my testing with gnome-terminal, running echo "https://example.com/really-long-link-to-test-a-line-break-that-is-well-over-the-default-80-character-line-length-to-force-the-terminal-to-automatically-wrap-this-text" will automatically wrap as handled by the terminal, and is still a valid and clickable link, as shown below. Glow/glamour handles rendering the markdown differently than expected, however. The markdown is not turned into a hyperlink within the terminal, which I understand as it means that even if your terminal doesn't support the special hyperlink escape sequences it can still identify the full link to automatically turn it into a clickable link, or allow you to copy and paste it into a web browser. Here is an illustration of the differences I am talking about: IMO, the first hyperlink option is easily the cleanest, but I understand that it may not work on every terminal. The second option clearly works as an alternative, which is fine. The problem arises with the third method. Glow identifies that the terminal width is 80 and manually tells the text to wrap, instead of letting the terminal handle it. This breaks the link. If I tell glow to ignore the terminal width and use a wrap length longer than the link, the terminal wraps it automatically and the link still works. |
Ok - follow up here. I attempted to using the styling json for glamour/glow to make the hyperlinking work, but unfortunately the order glamour puts them in is incorrect for what the hyperlink expects, and without making modifications to glow this seems impossible. My json was as follows: {
"link": {
"block_prefix": "\\033\\\\",
"block_suffix": "\\033]8;;\\033\\\\\n"
},
"link_text": {
"block_prefix": "\\033]8;;"
}
} But unfortunately, glow doesn't actually listen to the escape sequences: Wrapping the whole thing inside an echo will have it listen to the escape sequences and render correctly: But as you can see, the link and the link_text are flipped. This is not the way the terminal hyperlink expects it. Again, not an easy fix to this other than modifying glamour's code. Luckily, there seem to already be some people aware of this and working on it: Glamour: Feature: Support 'modern' anchors through ANSI OSC 8 escapes, and Github CLI: Auto-detected links with new lines result in 404s when clicked |
Thanks for your research! As it's not an issue with this project, I'll close this issue. |
Hi! When my terminal width is too narrow, text automatically wraps which ends up breaking long links. Below is a screenshot:
This means that only the first line of the hyperlink is active: https://github.com/ValveSoftware/steam-for- which gives a 404, obviously. I have attempted to read through glow's documentation and issues for anyone referencing this issue but have found no such mention of it.
Additionally, I notice that with glow, the markdown fails to make the text an actual hyperlink, instead just coloring it and underlining it.
Using escape sequences, it is possible to do this in terminal:
This acts as a valid hyperlink, and is additionally immune to this sort of text wrapping issue, as demonstrated here:
Not sure if this would best be solved with code changes to this repo, or if this may be better targeted towards glow.
Thanks!
The text was updated successfully, but these errors were encountered: