From: Simon Tatham Date: Thu, 7 Dec 2023 05:35:32 +0000 (+0000) Subject: Support in post content. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=f0d7c2708679dcd7d9ab3f1bef87ee3a2f093d68;p=mastodonochrome.git Support in post content. I just received a reply containing one. --- diff --git a/text.py b/text.py index 43220b9..f18e30e 100644 --- a/text.py +++ b/text.py @@ -21,6 +21,7 @@ colourmap = { 'c': [0, 33], # tags '#': [0, 36], # #hashtags '@': [0, 32], # @mentions of a user + '_': [0, 4], # tags 's': [0, 1], # tags 'u': [0, 1, 4, 34], # URL 'M': [0, 1, 4, 35], # media URL @@ -397,6 +398,10 @@ class HTMLParser(html.parser.HTMLParser): self.colourstack.append('s') return + if tag == "em": + self.colourstack.append('_') + return + # FIXME: need
, e.g. in
         # https://neuromatch.social/@mstimberg/111375114784712346
         # and _perhaps_ that ought to generate paragraphs with a
@@ -413,7 +418,7 @@ class HTMLParser(html.parser.HTMLParser):
                 self.paras.append(Paragraph())
             return
 
-        if tag in {"a", "code", "strong"}:
+        if tag in {"a", "code", "strong", "em"}:
             self.colourstack.pop()
             return