From 6011840d1f8be97214ee16a4d4d73e1870d53a3a Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sat, 10 Jun 2023 09:32:49 +0000 Subject: [PATCH] feat: markdown render support --- model/command/command.py | 4 ++-- util/general_utils.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/model/command/command.py b/model/command/command.py index 40289b1cd..c072e9c72 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -312,9 +312,9 @@ class Command: msg += f"`{key}` - {value}\n" # plugins if cached_plugins != None: - plugin_list_info = "\n".join([f"`{k}` {v['info']['name']}\n简介: \n{v['info']['desc']}\n" for k, v in cached_plugins.items()]) + plugin_list_info = "\n".join([f"`{k}` {v['info']['name']}\n{v['info']['desc']}\n" for k, v in cached_plugins.items()]) if plugin_list_info.strip() != "": - msg += "## 插件列表\n> 使用plugin v 插件名 查看插件帮助\n" + msg += "\n## 插件列表\n> 使用plugin v 插件名 查看插件帮助\n" msg += plugin_list_info msg += notice diff --git a/util/general_utils.py b/util/general_utils.py index 1aa67c4bd..495407e75 100644 --- a/util/general_utils.py +++ b/util/general_utils.py @@ -172,7 +172,7 @@ def render_markdown(markdown_text, image_width=800, image_height=600, font_size= continue if line.startswith("#"): header_level = line.count("#") - height += 58 - header_level * 4 + height += 62 - header_level * 4 elif line.startswith("-"): height += font_size+5 elif line.startswith(">"): @@ -186,7 +186,7 @@ def render_markdown(markdown_text, image_width=800, image_height=600, font_size= pre_in_code = True height += 5 elif re.search(r"`(.*?)`", line): - height += font_size+20 + height += font_size+25 else: height += font_size+5 @@ -260,7 +260,7 @@ def render_markdown(markdown_text, image_width=800, image_height=600, font_size= # 处理标题 header_level = line.count("#") line = line.strip("#").strip() - font_size = 28 - header_level * 4 + font_size = 32 - header_level * 4 # if unicode_emoji != "": # emoji_url = emoji_base_url.format(unicode_emoji=unicode_emoji[-5:]) @@ -288,7 +288,7 @@ def render_markdown(markdown_text, image_width=800, image_height=600, font_size= draw.line((x, y, x, y + font_size + 10), fill=(230, 230, 230), width=5) font = ImageFont.truetype(font_path, font_size) draw.text((x + 5, y + 5), quote_text, font=font, fill=(180, 180, 180)) - y += font_size + 10 + y += font_size + 20 # y += 16+5 elif line.startswith("-"):