From 3fc8a3bcd88927cb7cfeb06840dfb7cc3a132f39 Mon Sep 17 00:00:00 2001 From: hkc Date: Fri, 13 Jan 2023 10:40:40 +0300 Subject: [PATCH] Added ordered list --- mastoposter/utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mastoposter/utils.py b/mastoposter/utils.py index d8de714..8ec6d6e 100644 --- a/mastoposter/utils.py +++ b/mastoposter/utils.py @@ -86,6 +86,17 @@ def node_to_html(el: PageElement) -> str: ), ) ), + "ol": lambda tag: ( + "%s" + % str.join( + "\n", + ( + "%d. %s" + % (i, node_to_html(li).replace("\n", "\n ").strip()) + for i, li in enumerate(tag.children, 1) + ), + ) + ), } TAG_SUBSTITUTIONS: Dict[str, str] = { @@ -157,6 +168,17 @@ def node_to_markdown(el: PageElement) -> str: ), ) ), + "ol": lambda tag: ( + "\n``%s``\n" + % str.join( + "\n", + ( + "%d. %s" + % (i, node_to_markdown(li).replace("\n", "\n ").strip()) + for i, li in enumerate(tag.children, 1) + ), + ) + ), } TAG_SUBSTITUTIONS: Dict[str, str] = {