]> git.scottworley.com Git - paperdoorknob/blobdiff - glowfic.py
Strip links from meta fields
[paperdoorknob] / glowfic.py
index 065c71523cb1ae71b1b3da0dc9686c6ce540fc0e..8561cd756236bc1c5bf37c2b913ac91fad0b6a77 100644 (file)
@@ -89,13 +89,25 @@ def makeChunk(chunk_dom: Tag, image_store: ImageStore) -> Chunk:
         assert tag is None or isinstance(tag, Tag)
         return tag
 
         assert tag is None or isinstance(tag, Tag)
         return tag
 
+    def stripHREF(tag: Tag) -> None:
+        for c in tag.findChildren("a"):
+            if "href" in c.attrs:
+                del c.attrs["href"]
+
+    def getMeta(css_class: str) -> Tag | None:
+        tag = getByClass(css_class)
+        if tag is None:
+            return None
+        stripHREF(tag)
+        return tag
+
     content = chunk_dom.findChild('div', class_='post-content')
     assert isinstance(content, Tag)
 
     return Chunk(getIcon(),
     content = chunk_dom.findChild('div', class_='post-content')
     assert isinstance(content, Tag)
 
     return Chunk(getIcon(),
-                 getByClass('post-character'),
-                 getByClass('post-screenname'),
-                 getByClass('post-author'),
+                 getMeta('post-character'),
+                 getMeta('post-screenname'),
+                 getMeta('post-author'),
                  content)
 
 
                  content)