def read_component(thing):
if isinstance(thing, Tag):
if thing.name == "em":
return "*" + read_component(thing.next_element) + "*"
elif thing.name == "strong":
return "**" + read_component(thing.next_element) + "**"
elif thing.name == "u":
return "__" + read_component(thing.next_element) + "__"
elif thing.attrs.get("style") == "text-decoration: line-through;":
return "~~" + read_component(thing.next_element) + "~~"
elif thing.attrs.get("id") is not None and "footnoteref" in \
thing.attrs["id"]:
return ""
else:
return read_component(thing.next_element)
else:
return thing
评论列表
文章目录