Toot-Mastodon-CLI-TUI-clien.../toot/tui/richtext/__init__.py

19 lines
505 B
Python
Raw Permalink Normal View History

import urwid
from toot.tui.utils import highlight_hashtags
from toot.utils import format_content
from typing import List
try:
2023-11-16 11:46:54 +01:00
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)
]
2023-11-16 11:46:54 +01:00
def url_to_widget(url: str):
return urwid.Text(("link", url))