diff --git a/playground/markdownify_case.py b/playground/markdownify_case.py index 6e221b9..d4e1a08 100644 --- a/playground/markdownify_case.py +++ b/playground/markdownify_case.py @@ -99,7 +99,7 @@ print("Hello, World!") ``` This is `inline code` -1. First ordered list item +1. **First ordered list item** 2. Another item - Unordered sub-list. - Another item. diff --git a/playground/telegramify_case.py b/playground/telegramify_case.py index 1bb6bc2..074a104 100644 --- a/playground/telegramify_case.py +++ b/playground/telegramify_case.py @@ -3,6 +3,7 @@ import pathlib from time import sleep +from aiohttp import ClientSession from dotenv import load_dotenv from telebot import TeleBot @@ -32,12 +33,15 @@ # Write an async function to send message async def send_message(): - boxs = await telegramify_markdown.telegramify( - content=md, - interpreters_use=[BaseInterpreter(), MermaidInterpreter()], # Render mermaid diagram - latex_escape=True, - max_word_count=4090 # The maximum number of words in a single message. - ) + global_session = ClientSession() + async with global_session: + boxs = await telegramify_markdown.telegramify( + content=md, + interpreters_use=[BaseInterpreter(), MermaidInterpreter(session=global_session)], # Render mermaid diagram + latex_escape=True, + normalize_whitespace=True, + max_word_count=4090 # The maximum number of words in a single message. + ) for item in boxs: print("Sent one item") sleep(0.2) diff --git a/src/telegramify_markdown/render.py b/src/telegramify_markdown/render.py index 5ba3db0..90afd0e 100644 --- a/src/telegramify_markdown/render.py +++ b/src/telegramify_markdown/render.py @@ -238,7 +238,9 @@ def render_list_item( ) -> Iterable[str]: token_origin = str(token.leader).strip() if token_origin.endswith("."): - token.leader = formatting.escape_markdown(token.leader) + " " + if not token.leader.endswith(" "): + token.leader += " " + token.leader = formatting.escape_markdown(token.leader) else: token.leader = formatting.escape_markdown("⦁") return super().render_list_item(token, max_line_length)