Git Product home page Git Product logo

Comments (8)

b3nj5m1n avatar b3nj5m1n commented on August 18, 2024 1

Thanks for your research!

As it's not an issue with this project, I'll close this issue.

from xdg-ninja.

EricAndrechek avatar EricAndrechek commented on August 18, 2024

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.

from xdg-ninja.

b3nj5m1n avatar b3nj5m1n commented on August 18, 2024

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.

from xdg-ninja.

b3nj5m1n avatar b3nj5m1n commented on August 18, 2024

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.

from xdg-ninja.

Ballasi avatar Ballasi commented on August 18, 2024

Isn't this related to the terminal's capability to create links automatically from text?

I cannot reproduce this on alacritty or gnome-terminal. What terminal are you using @EricAndrechek?

from xdg-ninja.

b3nj5m1n avatar b3nj5m1n commented on August 18, 2024

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.

That's what I was talking about. You can reproduce their issue using kitty though.

from xdg-ninja.

EricAndrechek avatar EricAndrechek commented on August 18, 2024

Upon closer inspection, this doesn't seem to be an issue with glow, you should be able to configure this.

I say it is an issue with glow, as I believe it should do that for you. When I write [a link](https://example.com) in markdown "a link", it creates a hyperlink. I don't have to specify line breaks or anything, it sorts that out for me. If the link wraps to a new line, the whole thing is still valid, it doesn't separate the URL onto two different lines making both lines invalid.

Isn't this related to the terminal's capability to create links automatically from text?

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.

image

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:
image

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.

from xdg-ninja.

EricAndrechek avatar EricAndrechek commented on August 18, 2024

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:
image

Wrapping the whole thing inside an echo will have it listen to the escape sequences and render correctly:
image

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

from xdg-ninja.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.