From f3ddb4a1d95bb9864a731498813811e5d5f09147 Mon Sep 17 00:00:00 2001 From: hkc Date: Fri, 13 Jan 2023 10:36:58 +0300 Subject: [PATCH] Added unordered lists --- mastoposter/utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mastoposter/utils.py b/mastoposter/utils.py index 3474908..d8de714 100644 --- a/mastoposter/utils.py +++ b/mastoposter/utils.py @@ -75,6 +75,17 @@ def node_to_html(el: PageElement) -> str: ), ), "br": lambda _: "\n", + "ul": lambda tag: ( + "%s" + % str.join( + "\n", + ( + " \u2022 " + + node_to_html(li).replace("\n", "\n ").strip() + for li in tag.children + ), + ) + ), } TAG_SUBSTITUTIONS: Dict[str, str] = { @@ -135,6 +146,17 @@ def node_to_markdown(el: PageElement) -> str: ) ), "br": lambda _: "\n", + "ul": lambda tag: ( + "\n``%s``\n" + % str.join( + "\n", + ( + " \u2022 " + + node_to_markdown(li).replace("\n", "\n ").strip() + for li in tag.children + ), + ) + ), } TAG_SUBSTITUTIONS: Dict[str, str] = {