This regex might be a li'l Pleroma specific.
---
I guess that's why I didn't send it before. I like the feature
but I don't think this is the most robust implementation.
toot/utils/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/toot/utils/__init__.py b/toot/utils/__init__.py
index f21d425..d28ceee 100644
--- a/toot/utils/__init__.py+++ b/toot/utils/__init__.py
@@ -32,7 +32,7 @@ def parse_html(html: str) -> BeautifulSoup:
def get_text(html: str) -> str:
"""Converts html to text, strips all tags."""
- text = parse_html(html).get_text()+ text = parse_html(re.sub('<span class="h-card".*?mention".*?href="[a-z]+://([^/]+).*?@<span>([^<]+)</span></a></span>', r'@\2@\1', html)).get_text() return unicodedata.normalize("NFKC", text)
--
2.39.2
My only instance is an Akkoma instance and I've been dogfooding it
on there since mid February. Works fine there.
"Ivan Habunek" <ivan@habunek.com> writes:
> I should test this one a bit against pleroma/akkoma/etc before applying.>> -- Ivan
I ran into a problem with it today with a post that had this
Content:
<p><span class=\"h-card\"><a
href=\"https://idiomdrottning.org/users/Sandra\" class=\"u-url
mention\">@<span>Sandra</span></a></span> And do you like it? I
know snac2 had it but I hated it (or the particular
implementation). <span class=\"h-card\"><a
href=\"https://mathstodon.xyz/@bremner\" class=\"u-url
mention\">@<span>bremner</span></a></span></p>
https://social.alexschroeder.ch/@alex/statuses/01J1SB3J7QEFSGVZBK8126YKF0
It just showed:
@bremner@mathstodon.xyz
I'm probably gonna unapply this patch now that I'm using
toot status --json $1 | jq -r '..|select(.acct?).acct' | mawk
'!s[$0]++' | grep -v '^Sandra$' | sed 's;^;@;'
to get usernames in my reply script anyway, not having to paste
them in from the post.