strip html from mastodon tootline

workspace
Brendan Howell 7 years ago
parent da4afbd261
commit 424488a306

@ -7,6 +7,7 @@ import textwrap
import string import string
import urllib import urllib
import bleach
from escpos import printer from escpos import printer
import facebook import facebook
from mastodon import Mastodon from mastodon import Mastodon
@ -287,7 +288,7 @@ class PublicRelations(Bureau):
prn._raw(username) prn._raw(username)
prn.text("\r\n") prn.text("\r\n")
prn.set(text_type="NORMAL") prn.set(text_type="NORMAL")
ttext = html.unescape(t.content) ttext = bleach.clean(t.content, strip=True)
t_wrapped = textwrap.fill(ttext, width=48) + "\r\n" t_wrapped = textwrap.fill(ttext, width=48) + "\r\n"
t_enc = t_wrapped.encode("cp437", "ignore") t_enc = t_wrapped.encode("cp437", "ignore")
prn._raw(t_enc) prn._raw(t_enc)

Loading…
Cancel
Save