This gives us the flexibility to process non-flat URLs, which is useful
for shorter feedback cycles during development.
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'),
from images import FakeImageStore
from glowfic import chunkDOMs, makeChunk
from images import FakeImageStore
from glowfic import chunkDOMs, makeChunk
+from texify import PandocTexifier
class TestSplit(unittest.TestCase):
class TestSplit(unittest.TestCase):
self.assertEqual(str(c.content),
'<div class="post-content"><p></p></div>')
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()
if __name__ == '__main__':
unittest.main()