Replies: 2 comments 5 replies
-
Hi @ronf There is no obvious hook in Rich were you could enable that behaviour globally. Your idea re a custom renderable is sound. If you were to create a class that contained raw markup you could decide how it should look at the point of render. You could use that anywhere in Rich, including table cells. You would also need to implement a As for actually generating the LABEL (URL) text, you could customize markup.py or maybe post-process the text instance. Both would require dipping in to the Rich internals I'm afraid. I'll have a think about a way to make that easier. Maybe Rich could offer that behaviour, or at least make it easy to extend how markup is rendered. No promises on timescale... Will |
Beta Was this translation helpful? Give feedback.
-
There is an edge case here. Not sure if it affects you. Consider this bit of markup:
The
That works! I'd never considered doing it that way. You can avoid the overhead of parsing by adding Style objects, e.g.: style + console.get_style(link_style) |
Beta Was this translation helpful? Give feedback.
-
I've been thinking about starting to use the "link" style to add hyperlinks to some output, but I'd like to provide an alternate rendering of the text when on terminals that don't support them. Instead of just outputting the main text and throwing away the URL, I'm thinking of rendering it as something like "label (url)", e.g. "Google (https://www.google.com/)".
What makes this a bit tricky is that the text which contains the markup is entered by one user but then displayed later to another user who may have different terminal capabilities. So, I'd like to make the decision of what to display at rendering time. I'd also like to avoid need to parse the marked-up text myself looking for [link] tags.
Is there a straightforward way to provide an alternate renderer to what's in the style class? It seems like there might be a way to do it with a class that implements rich_console and wraps around a renderable, but I'd want it to be able to handle things like text with a link inside a table, running on the table cells before the table is rendered so that the wider version of the text with the visible URL is taken into account.
Beta Was this translation helpful? Give feedback.
All reactions