Skip to content
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

Add support for markdown links in paragraphs #6

Open
MartinBspheroid opened this issue Jan 6, 2025 · 1 comment
Open

Add support for markdown links in paragraphs #6

MartinBspheroid opened this issue Jan 6, 2025 · 1 comment
Labels
feature New feature or request

Comments

@MartinBspheroid
Copy link
Collaborator

Support clickable markdown links within paragraphs.
Use regex to detect markdown link syntax ([text](url)) in paragraph content and render them as HTML tags with appropriate attributes.
Links should be styled to match the classic underline design.

Ideas/Features:

  • Detect and render markdown links as clickable elements.
  • Ensure accessibility attributes like aria-label are added for screen readers.
  • Add test cases to verify proper detection and rendering of links.
@MartinBspheroid MartinBspheroid added the feature New feature or request label Jan 6, 2025
@orhun
Copy link
Owner

orhun commented Jan 6, 2025

The current way that this works is that we set a custom modifier style for the text that we want to render as hyperlink:

/// When added as a modifier to a style, the styled element is marked as hyperlink.
pub(crate) const HYPERLINK: Modifier = Modifier::SLOW_BLINK;

line: Span::from(url).style(HYPERLINK),

And then while rendering individual cells, we check this modifier and do some magic to wrap the related spans in an anchor tag (i.e. <a href="..."> </a>)

for (i, cell) in line.iter().enumerate() {
if cell.modifier.contains(HYPERLINK) {
// Start a new hyperlink

This is an approach that I adopted from webatui and I'm guessing the reason why they did that is there isn't a way to retrieve the widget data/metadata in the draw function of the backend.

This also limits our ability to attach arbitrary data to widgets, so I'm not sure if it would be possible to do custom text apart from url if we follow the same approach.

Maybe @joshka can give us some pointers about this 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants