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(),
- getByClass('post-character'),
- getByClass('post-screenname'),
- getByClass('post-author'),
+ getMeta('post-character'),
+ getMeta('post-screenname'),
+ getMeta('post-author'),
content)
from images import FakeImageStore
from glowfic import chunkDOMs, makeChunk
+from texify import PandocTexifier
class TestSplit(unittest.TestCase):
self.assertEqual(str(c.content),
'<div class="post-content"><p></p></div>')
+ self.assertEqual(
+ PandocTexifier("pandoc").texify(c.character), b'{Keltham}\n')
+
if __name__ == '__main__':
unittest.main()