Canop / termimad

A library to display rich (Markdown) snippets and texts in a rust terminal application
MIT License
901 stars 31 forks source link

Hyperlinks are not rendered correctly #48

Open patrickelectric opened 11 months ago

patrickelectric commented 11 months ago

https://anvilproject.org/guides/content/creating-links

image

segfaultsourcery commented 10 months ago

I'm interested in this as well. I would love for there to be buttons or links.

exor2008 commented 5 months ago

@patrickelectric @segfaultsourcery @ Any ideas, what exactly the links should look like? If this is a link to another md file, it can be clickable. But what if it's an actual http link? Something like Google search (https://google.com/)?

patrickelectric commented 5 months ago

That's a great question, I believe that it depends. It would be nice to have a configuration for such thing. I would believe that the showing the link is the best way for a presentation, but that should be up to who is presenting. If we do normal hyperlink without showing the link by default, the user would be free to add the link in the text. If we do otherwise, it'll not be possible for the user to remove it. So, if there will not be a setting for such behavior, I would vote for not having it.

segfaultsourcery commented 5 months ago

Would it be possible to implement a special class of link that somehow signals back what was clicked? What I mean by that is that I think it would be immensely useful if we could define a button in markdown, for example like this:

I am a button

If the button is clicked, the signal (this-is-a-signal) is emitted somewhere (perhaps a channel) where the developer can handle it.

On Thu, Apr 4, 2024, 06:40 exor2008 @.***> wrote:

@patrickelectric https://github.com/patrickelectric @segfaultsourcery https://github.com/segfaultsourcery @ Any ideas, what exactly the links should look like? If this is a link to another md file, it can be clickable. But what if it's an actual http link? Something like Google search (https://google.com/)?

— Reply to this email directly, view it on GitHub https://github.com/Canop/termimad/issues/48#issuecomment-2036179133, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGF4MBXO66HEA72URHDPITY3TKTRAVCNFSM6AAAAAA5NZQ5RKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZWGE3TSMJTGM . You are receiving this because you were mentioned.Message ID: @.***>

patrickelectric commented 5 months ago

Would it be possible to implement a special class of link that somehow signals back what was clicked? What I mean by that is that I think it would be immensely useful if we could define a button in markdown, for example like this: I am a button If the button is clicked, the signal (this-is-a-signal) is emitted somewhere (perhaps a channel) where the developer can handle it. On Thu, Apr 4, 2024, 06:40 exor2008 @.> wrote: @patrickelectric https://github.com/patrickelectric @segfaultsourcery https://github.com/segfaultsourcery @ Any ideas, what exactly the links should look like? If this is a link to another md file, it can be clickable. But what if it's an actual http link? Something like Google search (https://google.com/)? — Reply to this email directly, view it on GitHub <#48 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGF4MBXO66HEA72URHDPITY3TKTRAVCNFSM6AAAAAA5NZQ5RKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZWGE3TSMJTGM . You are receiving this because you were mentioned.Message ID: @.>

There is a terminal protocol just for that

exor2008 commented 5 months ago

I see it this way:

let mut skin = MadSkin::default();
skin.link.style = Link::TextAndLink // or Link::Text or Link::Link

where Link::TextAndLink will display

Google search (https://google.com/)

Link::Text will display

Google search

Link::Link will display

https://google.com/

Click on it will generate event, so developer can handle it. Like, display another md file or just ignore it if it was random http link.

exor2008 commented 5 months ago

@Canop what do you think?

Canop commented 5 months ago

@exor2008 There are two separate concerns here:

I'd rather keep the present issue focused on the expected link rendering, that is [a](b) would just display a but trigger a call to b URI using standard platform opener.

The reasons I didn't initially did it were:

The reason I don't do it now is just that I don't have time enough at the moment.

exor2008 commented 5 months ago

@Canop sure, it's a great job done already. Do you accept pull requests? Looks like, minimadshould be changed first here.

Canop commented 5 months ago

Do you accept pull requests?

I do accept a lot of them, but I'm cautious. See https://dystroy.org/blog/contributing/

Looks like, minimad should be changed first here.

Exact