Skip to content

Commit

Permalink
✨ feat(app): enhance Mermaid support check with logging
Browse files Browse the repository at this point in the history
Added a check for Mermaid support in the `MermaidInterpreter`
class. If unsupported, logs an error suggesting installing the
necessary libraries, preventing task processing without support.
This improves user guidance and debugging.
  • Loading branch information
sudoskys committed Jan 13, 2025
1 parent e04e3a1 commit 6436d87
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/telegramify_markdown/interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ async def render_task(self,
class MermaidInterpreter(BaseInterpreter):
name = "mermaid"
session = None
support = support_mermaid()

def __init__(self, session: "ClientSession" = None):
if not self.support:
logger.error(
"Mermaid is not supported because the required libraries are not installed. "
"Run `pip install telegramify-markdown[mermaid]` or remove MermaidInterpreter"
)
self.session = session

async def merge(self, tasks: List[TaskType]) -> List[TaskType]:
Expand All @@ -121,8 +127,8 @@ async def split(self, task: TaskType) -> List[TaskType]:
# 只处理 base 块
if task_type != "base":
return [task]
if not support_mermaid():
logger.error("Mermaid is not supported because the required libraries are not installed.")
# Do not produce new tasks if Mermaid is not supported
if not self.support:
return [task]
# 用于存放生成的新任务
tasks = []
Expand Down

0 comments on commit 6436d87

Please sign in to comment.