Textualize / textual

The lean application framework for Python. Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and a web browser.
https://textual.textualize.io/
MIT License
24.07k stars 741 forks source link

MD links inside a MD table in Markdown Widget do not generate Markdown.LinkClicked when clicked #4683

Closed dontascii closed 3 days ago

dontascii commented 4 days ago

Problem

When using the Markdown widget, links inside a table are not posting Markdown.LinkClicked events when they are clicked. The links are rendered properly, just not firing Markdown.LinkClicked.

Other links inside the document but outside of a table work as expected.

Expected Outcome:

Links inside tables generate Markdown.LinkClicked events

The following App renders some markdown which includes links inside and outside of a MD table. The links in the table do not generate the LinkClicked event, so no app notification will be displayed.

from textual import on
from textual.app import App, ComposeResult
from textual.widgets import Markdown 

EXAMPLE_MARKDOWN = """
# Markdown Document

[this link works](https://www.textualize.io/)

| [this title link does not work](https://www.textualize.io/) | col1 | col2 |
|-------|------|------|
| [does this one??](https://www.textualize.io/) | i  | wonder |
| foo | bar  | textual | 
"""
class SelectApp(App):

    def compose(self) -> ComposeResult:
        yield Markdown(EXAMPLE_MARKDOWN)

    @on(Markdown.LinkClicked)
    async def on_markdown_link_clicked(self, event: Markdown.LinkClicked) -> None:
        self.notify(f"on_markdown_link_clicked  - {event.href}")

if __name__ == "__main__":
    app = SelectApp()
    app.run() 

I've tried this on my windows 11 laptop as well as Ubuntu via wsl. Here are the textual diagnose outputs for both:

Textual Diagnostics for Windows 11

Versions

Name Value
Textual 0.70.0
Rich 13.7.1

Python

Name Value
Version 3.12.1
Implementation CPython
Compiler MSC v.1937 64 bit (AMD64)
Executable c:\Users\Joel.Clegg\source\python\beaz.venv\Scripts\python.exe

Operating System

Name Value
System Windows
Release 11
Version 10.0.22631

Terminal

Name Value
Terminal Application Windows Terminal
TERM Not set
COLORTERM Not set
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=143, height=37
legacy_windows False
min_width 1
max_width 143
is_terminal True
encoding utf-8
max_height 37
justify None
overflow None
no_wrap False
highlight None
markup None
height None

Textual Diagnostics for linux container

Versions

Name Value
Textual 0.58.0
Rich 13.7.1

Python

Name Value
Version 3.10.12
Implementation CPython
Compiler GCC 11.4.0
Executable /mnt/c/Users/Joel.Clegg/source/python/beaz/.env/bin/python3

Operating System

Name Value
System Linux
Release 5.15.153.1-microsoft-standard-WSL2
Version #1 SMP Fri Mar 29 23:14:13 UTC 2024

Terminal

Name Value
Terminal Application Windows Terminal
TERM xterm-256color
COLORTERM Not set
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=132, height=33
legacy_windows False
min_width 1
max_width 132
is_terminal True
encoding utf-8
max_height 33
justify None
overflow None
no_wrap False
highlight None
markup None
height None
github-actions[bot] commented 4 days ago

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

github-actions[bot] commented 3 days ago

Don't forget to star the repository!

Follow @textualizeio for Textual updates.