Skip to content

Hyperlink support#83

Open
uttarayan21 wants to merge 19 commits intomainfrom
hyperlink-support
Open

Hyperlink support#83
uttarayan21 wants to merge 19 commits intomainfrom
hyperlink-support

Conversation

@uttarayan21
Copy link
Copy Markdown
Collaborator

Implemented support for parsing hyperlinks directly.
Now the parsers return HyperlinkedText instead of Text.
The HyperlinkedText is rendered using the same method used in
https://github.com/JayanAXHF/gitv/tree/main/crates/hyperrat

Also I've cleaned up the text and text_fast and merged them into one since they were already basically the same. But previously we didn't have any methods to convert Text<'a> to Text<'static> which I've added in the new HyperlinkedText struct.

The examples/hyperlinks.rs was generated using AI which I've verified works inside kitty.

Also ran updated flake inputs to latest.

@uttarayan21 uttarayan21 self-assigned this Mar 11, 2026
@uttarayan21
Copy link
Copy Markdown
Collaborator Author

Fixes #82

This comment was marked as outdated.

@orhun
Copy link
Copy Markdown
Member

orhun commented Mar 13, 2026

Just tested the example code and works really nice!

I'm not sure if I will have the capacity to review all this but definitely looking forward 🐀 🧀

@uttarayan21
Copy link
Copy Markdown
Collaborator Author

The thing is I'm not sure if all the hyperlink stuff makes sense in this crate directly.
Maybe splitting into a ratatui-hyperlink makes sense ? And then use that to return ratatui_hyperlink::HyperlinkedText

from the for now we can ship a rc.1 with all this embedded and maybe later publish a crate called ratatui-hyperlink ?

@orhun
Copy link
Copy Markdown
Member

orhun commented Mar 14, 2026

Makes sense to me!

@uttarayan21
Copy link
Copy Markdown
Collaborator Author

uttarayan21 commented Apr 6, 2026

Just documenting things. Don't mind this comment.

Using the following code gives around a 21% perf regression compared to using an if-else

hyperlink_span.or(text_span).parse(s)
image

Whereas using the simple if-else yields back the performance compared to the .or method.

if let Some((s, h)) = hyperlink_span.parse(s).ok() {
    Ok((s, h))
} else {
    let (s, _) = cond(style.is_none(), opt(any_escape_sequence)).parse(s)?;
    text_span.parse(s)
}
image

overall performance regression compared to master
not noticeable in larger code example
image

@uttarayan21 uttarayan21 marked this pull request as ready for review April 7, 2026 13:15
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.

3 participants