chiark / gitweb /
Support <em> in post content.
authorSimon Tatham <anakin@pobox.com>
Thu, 7 Dec 2023 05:35:32 +0000 (05:35 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 7 Dec 2023 07:09:14 +0000 (07:09 +0000)
I just received a reply containing one.

text.py

diff --git a/text.py b/text.py
index 43220b94ef35171fe251ad0bac9fa1f5225d3c4a..f18e30e668862140164d02ad52f946acc42264ff 100644 (file)
--- a/text.py
+++ b/text.py
@@ -21,6 +21,7 @@ colourmap = {
     'c': [0, 33], # <code> tags
     '#': [0, 36], # #hashtags
     '@': [0, 32], # @mentions of a user
+    '_': [0, 4], # <em> tags
     's': [0, 1], # <strong> 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 <pre>, 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