Skip to main content

基于 Pillow 的可自定义 Markdown 风格渲染器,渲染速度快且易于配置

Project description

pillowmd

CustomMarkdownImage

✨ 基于pillow的可自定义markdown渲染器 ✨

license pypi python GitHub top language GitHub last commit PyPI - Downloads GitHub code size in bytes
LaTeX Markdown Pillow PillowLaTeX NoBrowser NoMatplotlib
QQ Chat Group QQ Channel

开始使用

使用pip install pillowmd

如何使用

先使用style = pillowmd.LoadMarkdownStyles(style路径),然后使用style.Render(markdown内容)即可快速渲染。若没有style,则可以pillowmd.MdToImage(内容)使用默认风格渲染

注:MdToImage是异步函数,若想使用默认风格进行同步渲染,请使用:

import pillowmd
style = pillowmd.MdStyle()
style.Render("# Is Markdown")

自定义style

docs目录下的how_to……,里面有进一步指南,也可以进入Q群498427849

使用例

见tests目录

元素支持

markdown元素

元素 样例 是否支持 备注
标题 # 标题 ✅️ 仅支持1~3级标题
引用 > 123 ✅️
无序列表 * 123
* 123
✅️
有序列表 1. 123
2. 123
✅️
行中代码 这是`行中代码` ✅️ 不支持高亮
行中表达式 这是$行中表达式$ ✅️ 支持latex,且支持latex拆分换行,详见pillowlatex
表格 |这是|表格|
|-|-|
|1|2|
✅️ 表格中仅支持普通文本,且不支持自定义对其方式。会自动换行
代码块 ```python
print("hello world")
```
✅️ 不支持高亮
行间表达式 &&
\frac{1}{2}
&&
✅️ 支持latex,且支持latex拆分换行,详见pillowlatex
HTML <br> ❎️ 暂不支持

额外元素

元素 样例 备注
自定义颜色 <color=#FF0000> 强制更改颜色,填入#xxxxxx格式的颜色,填入None则为取消强制更改
快捷图片 !sgm[图片名]
!sgm[图片名|比例]
!sgm[图片名|x比例,y比例]
需要设置快捷图片路径,可在渲染时取消使用该元素
自定义元素 !sgexter[元素名,参数……]
!sgexter[card,"title","content",800,400,"图片.jpg"]
可在渲染时取消使用该元素

渲染差异

当仅有一个\n时,也会换行

图片预览

元素预览 元素预览 分页+侧边图渲染 额外效果 新版本LaTeX支持 额外效果

Style下载

github

其他

欢迎各位分享你自己的style风格,联系QQ614675349,或者直接在GitHub上提交PR

更新日志

0.7.0

新增行间latex支持,优化readme,现在引用一级的线会被渲染出来了

0.6.0

新增latex支持,详见pillowlatex

0.5.3

修复了表格渲染会错误的在前后加上行间距的问题 增加了表格的debug显示

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pillowmd-0.7.3.tar.gz (20.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pillowmd-0.7.3-py3-none-any.whl (20.2 MB view details)

Uploaded Python 3

File details

Details for the file pillowmd-0.7.3.tar.gz.

File metadata

  • Download URL: pillowmd-0.7.3.tar.gz
  • Upload date:
  • Size: 20.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for pillowmd-0.7.3.tar.gz
Algorithm Hash digest
SHA256 4be5c16768c5dad643b897784a097fd038059514cd5abdd005150e057559edd8
MD5 56d6abff8ab6ae58d9e6f84f560bde5c
BLAKE2b-256 9ee8869d3bf879e84c2e88d7e0f8a21ab31221cc0f29ff77b3e52cd2a2828d14

See more details on using hashes here.

File details

Details for the file pillowmd-0.7.3-py3-none-any.whl.

File metadata

  • Download URL: pillowmd-0.7.3-py3-none-any.whl
  • Upload date:
  • Size: 20.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for pillowmd-0.7.3-py3-none-any.whl
Algorithm Hash digest
SHA256 13fe0200905f159919cdb05052e0e4d54b806db7c0e96a99e479ba8a3b6f6bfc
MD5 bc29bf8215cd6caaad8daca0ecd558a4
BLAKE2b-256 c9be7860ebfdbbb32b9454814569c62b9f5cfc5a8ba88e415eea65840d6a9b45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page