feat: markdown render support

This commit is contained in:
Soulter
2023-06-10 09:32:49 +00:00
parent 9a2dffe299
commit 6011840d1f
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -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
+4 -4
View File
@@ -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("-"):