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

Support to display a limited set of HTML tags (aligned with mastodon 4.2) plus URL support (soft dependency on urwidgets library) #403

Closed

Conversation

danschwarz
Copy link
Collaborator

This is essentially a rewrite of the closed PR #348 using @AnonymouX47 's TextEmbed widget from urwidgets. It does not suffer from the rendering issue that caused problems for the previous PR, that used urwid.Text. As a bonus, it includes support for clickable links on terminals that support OCS 8 hyperlinks.

If urwidgets library is not available, we fall back seamlessly to using urwid.Text and everything works as normal, you just don't get clickable links on terminals that support OCS 8 hyperlinks.

This PR renders all HTML elements, and some HTML attributes, that are supported in Mastodon 4.2 spec

HTML Status on a glitch-soc server

image

The same status on the TUI with this PR

image

As the urwidgets dependency is Python 3.7+, I have removed the Python 3.6 automated Github tests.

danschwarz and others added 30 commits March 31, 2023 21:06
Title is now a positional parameter.

Also added some error handling in the command processing
for looking up list IDs per @ihabunek 's suggestions
Also don't check if account is found, that function alredy raises a
ConsoleError.
Top level widgets are separated by blank lines, but
The final blank line of the status is omitted. This exactly
matches existing status rendering in master, for statuses that
contain only the currently supported tags
No longer specifying color "white" when it's more correct to
omit the color and just specify an attribute like underline,
bold, etc.
If the class name appears in the constants.py PALETTE entry, it is
honored. Otherwise, the class is ignored and the tag is handled
as a generic tag of that type.  This allows hashtag anchors
to be highlighted, and URL anchors to be styled differently
regardless of the strange class markup that Akkoma adds to URL
anchors
danschwarz and others added 23 commits April 4, 2023 19:43
Uses the Hyperlink widget along with TextEmbed widget
We see this problem with statuses from Pixelfed servers.
Per the Mastodon API spec, the content tag is supposed to be
HTML, but Pixelfed sends statuses that often start as plain text.
They may include embedded anchor tags etc. within the text.
This confuses BeautifulSoup HTML parsers and results in bad
rendering artifacts.

This workaround detects the above condition and attempts to fix it by
surrounding the status in <p></p>. This converts it to nominally
valid HTML (at least, parseable by BeautifulSoup.)
Also, hashtags are created as OCS-8 hyperlinks, so they are
directly clickable in terminals that support OCS-8
Also, now renders HTML in Account overlay page
Also, removed Python 3.6 tests as urwidgets is Python 3.7+
Pleroma, Akkoma, and other servers do not follow the Mastodon spec
for the 'uri' attribute which specifies that it contains the domain
name of the instance. Instead, they return a complete URI.

As a workaround, we now detect this situation and parse out the
domain from the URI when necessary. This fixes issue ihabunek#347.

Thanks to @laleanor for their patch and @rjp for ideas on how to
make it work with GotoSocial and other servers
Previously this only worked for anchor tags with nested spans.
Now it works for anchor tags with or without nested spans.
@danschwarz
Copy link
Collaborator Author

"workflow runs completed with no jobs"
🤔

@danschwarz
Copy link
Collaborator Author

See new simplified PR with all changes squashed into a single commit #404

@danschwarz danschwarz closed this Sep 23, 2023
@danschwarz danschwarz deleted the rt-hyperlinks-urwidgets-stub branch January 21, 2024 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants