1
0
mirror of https://github.com/ihabunek/toot synced 2025-01-10 16:52:40 +01:00
Toot-Mastodon-CLI-TUI-clien.../toot/tui/richtext/__init__.py
2023-11-16 11:46:54 +01:00

19 lines
505 B
Python

import urwid
from toot.tui.utils import highlight_hashtags
from toot.utils import format_content
from typing import List
try:
from .richtext import html_to_widgets, url_to_widget
except ImportError:
# Fallback if urwidgets are not available
def html_to_widgets(html: str) -> List[urwid.Widget]:
return [
urwid.Text(highlight_hashtags(line))
for line in format_content(html)
]
def url_to_widget(url: str):
return urwid.Text(("link", url))