Skip to content

Commit

Permalink
✨ feat(playground/markdownify_case.py): bold first list item
Browse files Browse the repository at this point in the history
πŸ› fix(render.py): ensure space after escaped markdown leader

πŸ”§ chore(playground/telegramify_case.py): add aiohttp for async messaging
  • Loading branch information
sudoskys committed Dec 15, 2024
1 parent 97371c4 commit 22c9b13
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion playground/markdownify_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 10 additions & 6 deletions playground/telegramify_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pathlib
from time import sleep

from aiohttp import ClientSession
from dotenv import load_dotenv
from telebot import TeleBot

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/telegramify_markdown/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 22c9b13

Please sign in to comment.