diff --git a/app.py b/app.py index 3ae3498..2da1358 100644 --- a/app.py +++ b/app.py @@ -34,7 +34,7 @@ from flask import request from flask import session from flask import url_for from flask_wtf.csrf import CSRFProtect -from html2text import html2text +import html2text from itsdangerous import BadSignature from little_boxes import activitypub as ap from little_boxes.activitypub import ActivityType @@ -123,6 +123,10 @@ else: SIG_AUTH = HTTPSigAuth(KEY) +H2T = html2text.HTML2Text() +H2T.ignore_links = True +H2T.ignore_images = True + def is_blacklisted(url: str) -> bool: return urlparse(url).netloc in BLACKLIST @@ -340,7 +344,7 @@ def clean(html): @app.template_filter() def html2plaintext(body): - return html2text(body) + return H2T.handle(body) @app.template_filter() diff --git a/templates/layout.html b/templates/layout.html index 65ff664..284256f 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -4,7 +4,7 @@ -