-
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 PR #23913) plus URL support #356
Conversation
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+
c4b41ba
to
6109257
Compare
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.
Update- I've got a new version of this PR that removes the hard dependency on the urwidgets library. If you have urwidgets installed, it works with full functionality including OCS 8 support for hyperlinks. If you do not have urwidgets, it still works, all HTML tags are shown properly, but hyperlinks display as plain text. When it's good enough to submit, I'll close out this PR and open up a new one. |
Closed in favor of #403 PR which is the same code as above, without the hard dependency |
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.This PR renders all HTML elements, and some HTML attributes, that will be 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.