nonebot-plugin-htmlrender 0.2.1__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/PKG-INFO +14 -1
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/README.md +13 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/browser.py +11 -5
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/config.py +1 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/pyproject.toml +1 -1
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/LICENSE +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/__init__.py +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/data_source.py +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/templates/github-markdown-light.css +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/templates/katex/katex.min.b64_fonts.css +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/templates/katex/katex.min.js +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/templates/katex/mathtex-script-type.min.js +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/templates/markdown.html +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/templates/pygments-default.css +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/templates/text.css +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/nonebot_plugin_htmlrender/templates/text.html +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/__init__.py +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/conftest.py +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/templates/markdown.css +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/templates/mystyle.css +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/templates/text.html +0 -0
- {nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/test_htmlrender.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-htmlrender
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: 通过浏览器渲染图片
|
|
5
5
|
Author-Email: kexue <xana278@foxmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -77,6 +77,19 @@ from nonebot_plugin_htmlrender import (
|
|
|
77
77
|
htmlrender_browser = "chromium"
|
|
78
78
|
# 使用 firefox
|
|
79
79
|
htmlrender_browser = "firefox"
|
|
80
|
+
|
|
81
|
+
# 下载 playwright 代理地址 可不写
|
|
82
|
+
htmlrender_download_host = ""
|
|
83
|
+
|
|
84
|
+
# 浏览器自定代理地址 可不写
|
|
85
|
+
htmlrender_proxy_host = "http://127.0.0.1:7890"
|
|
86
|
+
|
|
87
|
+
# 浏览器 channel 支持以下
|
|
88
|
+
# "chrome", "chrome-beta", "chrome-dev", "chrome-canary",
|
|
89
|
+
# "msedge", "msedge-beta", "msedge-dev", "msedge-canary"
|
|
90
|
+
# 手动编辑可以直接使用系统自带浏览器而不用重新下载 chromium
|
|
91
|
+
# 可不写
|
|
92
|
+
htmlrender_browser_channel = ""
|
|
80
93
|
```
|
|
81
94
|
|
|
82
95
|
## markdown 转 图片
|
|
@@ -38,6 +38,19 @@ from nonebot_plugin_htmlrender import (
|
|
|
38
38
|
htmlrender_browser = "chromium"
|
|
39
39
|
# 使用 firefox
|
|
40
40
|
htmlrender_browser = "firefox"
|
|
41
|
+
|
|
42
|
+
# 下载 playwright 代理地址 可不写
|
|
43
|
+
htmlrender_download_host = ""
|
|
44
|
+
|
|
45
|
+
# 浏览器自定代理地址 可不写
|
|
46
|
+
htmlrender_proxy_host = "http://127.0.0.1:7890"
|
|
47
|
+
|
|
48
|
+
# 浏览器 channel 支持以下
|
|
49
|
+
# "chrome", "chrome-beta", "chrome-dev", "chrome-canary",
|
|
50
|
+
# "msedge", "msedge-beta", "msedge-dev", "msedge-canary"
|
|
51
|
+
# 手动编辑可以直接使用系统自带浏览器而不用重新下载 chromium
|
|
52
|
+
# 可不写
|
|
53
|
+
htmlrender_browser_channel = ""
|
|
41
54
|
```
|
|
42
55
|
|
|
43
56
|
## markdown 转 图片
|
|
@@ -42,10 +42,16 @@ async def init(**kwargs) -> Browser:
|
|
|
42
42
|
return _browser
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
async def launch_browser(
|
|
45
|
+
async def launch_browser(**kwargs) -> Browser:
|
|
46
46
|
assert _playwright is not None, "Playwright 没有安装"
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
|
|
48
|
+
if config.htmlrender_browser_channel:
|
|
49
|
+
kwargs["channel"] = config.htmlrender_browser_channel
|
|
50
|
+
|
|
51
|
+
if config.htmlrender_proxy_host:
|
|
52
|
+
kwargs["proxy"] = {
|
|
53
|
+
"server": config.htmlrender_proxy_host,
|
|
54
|
+
}
|
|
49
55
|
if config.htmlrender_browser == "firefox":
|
|
50
56
|
logger.info("使用 firefox 启动")
|
|
51
57
|
return await _playwright.firefox.launch(**kwargs)
|
|
@@ -61,9 +67,9 @@ async def get_browser(**kwargs) -> Browser:
|
|
|
61
67
|
|
|
62
68
|
|
|
63
69
|
@asynccontextmanager
|
|
64
|
-
async def get_new_page(device_scale_factor:float = 2
|
|
70
|
+
async def get_new_page(device_scale_factor: float = 2, **kwargs) -> AsyncIterator[Page]:
|
|
65
71
|
browser = await get_browser()
|
|
66
|
-
page = await browser.new_page(device_scale_factor=device_scale_factor
|
|
72
|
+
page = await browser.new_page(device_scale_factor=device_scale_factor, **kwargs)
|
|
67
73
|
try:
|
|
68
74
|
yield page
|
|
69
75
|
finally:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/templates/markdown.css
RENAMED
|
File without changes
|
{nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/templates/mystyle.css
RENAMED
|
File without changes
|
{nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/templates/text.html
RENAMED
|
File without changes
|
{nonebot_plugin_htmlrender-0.2.1 → nonebot_plugin_htmlrender-0.2.3}/tests/test_htmlrender.py
RENAMED
|
File without changes
|