-
Notifications
You must be signed in to change notification settings - Fork 112
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
danschwarz
wants to merge
56
commits into
ihabunek:master
from
danschwarz:rt-hyperlinks-urwidgets-stub
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code is adapted from GPL3-licensed muv by @seonon https://github.com/seonon/muv
Code is adapted from GPL3-licensed muv by @seonon https://github.com/seonon/muv
see: https://www.flake8rules.com/rules/W503.html for justification
Fixes issue ihabunek#255
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
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+
Also converted polls.py to use HTML rendering
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.
"workflow runs completed with no jobs" |
See new simplified PR with all changes squashed into a single commit #404 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is essentially a rewrite of the closed PR #348 using @AnonymouX47 's
TextEmbed
widget fromurwidgets
. It does not suffer from the rendering issue that caused problems for the previous PR, that usedurwid.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
The same status on the TUI with this PR
As the
urwidgets
dependency is Python 3.7+, I have removed the Python 3.6 automated Github tests.