nonebot-plugin-htmlrender 0.7.1__py3-none-any.whl → 0.7.2__py3-none-any.whl
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/backend/playwright/operations.py +24 -11
- nonebot_plugin_htmlrender/templates/markdown/markdown.html +3 -3
- nonebot_plugin_htmlrender/templates/text/text.html +1 -1
- {nonebot_plugin_htmlrender-0.7.1.dist-info → nonebot_plugin_htmlrender-0.7.2.dist-info}/METADATA +1 -1
- {nonebot_plugin_htmlrender-0.7.1.dist-info → nonebot_plugin_htmlrender-0.7.2.dist-info}/RECORD +7 -7
- {nonebot_plugin_htmlrender-0.7.1.dist-info → nonebot_plugin_htmlrender-0.7.2.dist-info}/WHEEL +1 -1
- {nonebot_plugin_htmlrender-0.7.1.dist-info → nonebot_plugin_htmlrender-0.7.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -110,6 +110,11 @@ def _enum_value(raw: object) -> str:
|
|
|
110
110
|
return str(getattr(raw, "value", raw))
|
|
111
111
|
|
|
112
112
|
|
|
113
|
+
def _should_navigate_to_base_url(base_url: str) -> bool:
|
|
114
|
+
"""判断浏览器是否应先导航到页面的 base URL。"""
|
|
115
|
+
return base_url != "about:blank"
|
|
116
|
+
|
|
117
|
+
|
|
113
118
|
async def read_file(path: str) -> str:
|
|
114
119
|
"""异步读取文件内容。"""
|
|
115
120
|
f = await anyio.open_file(path, mode="r", encoding="utf-8")
|
|
@@ -264,7 +269,8 @@ async def render_html(
|
|
|
264
269
|
),
|
|
265
270
|
) as page,
|
|
266
271
|
):
|
|
267
|
-
|
|
272
|
+
remote_mode = is_remote_playwright_mode()
|
|
273
|
+
if remote_mode and (
|
|
268
274
|
_enum_value(get_playwright_config().remote_local_resource_policy)
|
|
269
275
|
== RemoteLocalResourcePolicy.FILEHOST.value
|
|
270
276
|
):
|
|
@@ -274,7 +280,9 @@ async def render_html(
|
|
|
274
280
|
)
|
|
275
281
|
|
|
276
282
|
_setup_page_logging(page)
|
|
277
|
-
|
|
283
|
+
base_url = render_request.render.page.base_url
|
|
284
|
+
if _should_navigate_to_base_url(base_url):
|
|
285
|
+
await page.goto(base_url)
|
|
278
286
|
await page.set_content(
|
|
279
287
|
render_request.content.html,
|
|
280
288
|
wait_until=render_request.content.wait_until,
|
|
@@ -444,17 +452,16 @@ async def render_markdown(
|
|
|
444
452
|
)
|
|
445
453
|
css = github_css + pygments_css
|
|
446
454
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
)
|
|
451
|
-
|
|
452
|
-
|
|
455
|
+
if render is None:
|
|
456
|
+
base_url = (
|
|
457
|
+
_path_to_uri(css_path) if css_path else MARKDOWN_TEMPLATE_FILE.as_uri()
|
|
458
|
+
)
|
|
459
|
+
if is_remote_playwright_mode():
|
|
460
|
+
base_url = "about:blank"
|
|
461
|
+
render = RenderConfig(
|
|
453
462
|
page=PageConfig(
|
|
454
463
|
viewport=ViewportConfig(width=width, height=10),
|
|
455
|
-
base_url=
|
|
456
|
-
if css_path
|
|
457
|
-
else MARKDOWN_TEMPLATE_FILE.as_uri(),
|
|
464
|
+
base_url=base_url,
|
|
458
465
|
),
|
|
459
466
|
screenshot=_build_screenshot_config(
|
|
460
467
|
image_type,
|
|
@@ -464,7 +471,13 @@ async def render_markdown(
|
|
|
464
471
|
full_page=True,
|
|
465
472
|
wait_before_screenshot=0,
|
|
466
473
|
),
|
|
474
|
+
)
|
|
475
|
+
|
|
476
|
+
render_request = HtmlRenderRequest(
|
|
477
|
+
content=ContentConfig(
|
|
478
|
+
html=await template.render_async(md=md, css=css, extra=extra)
|
|
467
479
|
),
|
|
480
|
+
render=render,
|
|
468
481
|
)
|
|
469
482
|
|
|
470
483
|
return await render_html(render_request, session=session)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<meta charset="utf-8">
|
|
7
7
|
<style type="text/css">
|
|
8
|
-
{{ css }}
|
|
8
|
+
{{ css | safe }}
|
|
9
9
|
</style>
|
|
10
10
|
<style>
|
|
11
11
|
.markdown-body {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
<body>
|
|
28
28
|
<article class="markdown-body">
|
|
29
|
-
{{ md }}
|
|
29
|
+
{{ md | safe }}
|
|
30
30
|
</article>
|
|
31
31
|
</body>
|
|
32
|
-
{{ extra }}
|
|
32
|
+
{{ extra | safe }}
|
{nonebot_plugin_htmlrender-0.7.1.dist-info → nonebot_plugin_htmlrender-0.7.2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-htmlrender
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: 通过浏览器渲染图片
|
|
5
5
|
Project-URL: Homepage, https://github.com/kexue-z/nonebot-plugin-htmlrender
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/kexue-z/nonebot-plugin-htmlrender/issues
|
{nonebot_plugin_htmlrender-0.7.1.dist-info → nonebot_plugin_htmlrender-0.7.2.dist-info}/RECORD
RENAMED
|
@@ -16,7 +16,7 @@ nonebot_plugin_htmlrender/backend/playwright/config.py,sha256=2KQvNQtgm5tPsI_OTW
|
|
|
16
16
|
nonebot_plugin_htmlrender/backend/playwright/data_source.py,sha256=c4iQMrS9TnWcEPphUxiKQ682PySp55ljHnGsiMaahP4,3259
|
|
17
17
|
nonebot_plugin_htmlrender/backend/playwright/install.py,sha256=Z42LYmtujlqPfeuiKQ3UD8hUjDypJuKu5z-nNPAi9ns,5297
|
|
18
18
|
nonebot_plugin_htmlrender/backend/playwright/models.py,sha256=dXfRJaaKH6DjOPCHR5INmj9wH1ZMAg0W5Rk6U6kP-Kw,12785
|
|
19
|
-
nonebot_plugin_htmlrender/backend/playwright/operations.py,sha256=
|
|
19
|
+
nonebot_plugin_htmlrender/backend/playwright/operations.py,sha256=dnXpyK0N6ujn1D2-7gMdd5Gl7nykG6THOm5K-mgPoe8,24585
|
|
20
20
|
nonebot_plugin_htmlrender/backend/playwright/render.py,sha256=nJKa0kPvRwcGvUIStYFcGUrFoiCB-ab_Iguc9XbfRBE,28108
|
|
21
21
|
nonebot_plugin_htmlrender/backend/playwright/runtime.py,sha256=zKBoqD52zObmxirLmhm9DzO88jh59x8RzToFwpoDBZU,15330
|
|
22
22
|
nonebot_plugin_htmlrender/backend/playwright/telemetry.py,sha256=sgc78EIHzC-4WIYtsd6p8XzHtXGZ3VF8U_1xn0jjUns,8244
|
|
@@ -30,14 +30,14 @@ nonebot_plugin_htmlrender/resources/filehost/cache.py,sha256=BtAJs6BvpVhjVSILoFo
|
|
|
30
30
|
nonebot_plugin_htmlrender/resources/filehost/guard.py,sha256=thNqB44WOMxAV6w22DyOzB9R3VEkCGF9N9xDzQdtuDQ,5038
|
|
31
31
|
nonebot_plugin_htmlrender/resources/filehost/warmup.py,sha256=in9-GRTMJbRTlUh1k99b-VHYCUGDjBU0zPobVYbVWaM,8441
|
|
32
32
|
nonebot_plugin_htmlrender/templates/markdown/github-markdown-light.css,sha256=bWV9QiirgHYgauZBcR9YJ3IvEoA3fP2Cf5aOdshBVrI,17297
|
|
33
|
-
nonebot_plugin_htmlrender/templates/markdown/markdown.html,sha256=
|
|
33
|
+
nonebot_plugin_htmlrender/templates/markdown/markdown.html,sha256=RRuCJweJdTItgR81a6YLr84AtP2lvPDynpIIQojzjzY,651
|
|
34
34
|
nonebot_plugin_htmlrender/templates/markdown/pygments-default.css,sha256=lwkE40qSsvPe52nGAZW1luJ7qNeIWpgw7vDX-MZpCDA,4889
|
|
35
35
|
nonebot_plugin_htmlrender/templates/markdown/katex/katex.min.b64_fonts.css,sha256=8KXk7iVhFZ-h2LuWlhI6Eq2za2vuDW-n4MrHQJ2eRAU,1458204
|
|
36
36
|
nonebot_plugin_htmlrender/templates/markdown/katex/katex.min.js,sha256=cXQ4tsltOzinSxpNqnPldAdfpstIPXBDKihVb7ccZL0,270288
|
|
37
37
|
nonebot_plugin_htmlrender/templates/markdown/katex/mathtex-script-type.min.js,sha256=d-R93Fs6-ZBEU3VEH7u_qz-b02iCPKEPmLJEgRf2-MU,1290
|
|
38
38
|
nonebot_plugin_htmlrender/templates/markdown/katex/mhchem.min.js,sha256=8MoD3xlLjD1gF_9FXbag75iFeQVmP6MRps3teIsVNAs,33730
|
|
39
39
|
nonebot_plugin_htmlrender/templates/text/text.css,sha256=zhb6Yd3zndvojU4-qQR46dRg9CsCRvmyWU1-Uhm-2LQ,117
|
|
40
|
-
nonebot_plugin_htmlrender/templates/text/text.html,sha256=
|
|
40
|
+
nonebot_plugin_htmlrender/templates/text/text.html,sha256=1W30B9-66tjUb2t3ZIrxtA1V_u8zx_UD3Kv18ebK4tU,227
|
|
41
41
|
nonebot_plugin_htmlrender/utils/__init__.py,sha256=cQJgTRooe3ieFlGZoiuEvUPyxxDTjt9BpncEAuqvfA0,1201
|
|
42
42
|
nonebot_plugin_htmlrender/utils/install.py,sha256=K_vKbiSQIk6-_gveWLthezclXxzfOh3EGoUNpTu-PCQ,5325
|
|
43
43
|
nonebot_plugin_htmlrender/utils/process.py,sha256=bdX33f1aa_c0voedcthLrN-uBmLEGVreCtuwSPWiiNU,9050
|
|
@@ -46,7 +46,7 @@ nonebot_plugin_htmlrender/utils/telemetry/__init__.py,sha256=BrseDy_dtQbJi9psbRT
|
|
|
46
46
|
nonebot_plugin_htmlrender/utils/telemetry/common.py,sha256=MjA5nOR7bnSiLtNKx5GHKZJ8KfSsNWYo3rbPIs8QucU,4240
|
|
47
47
|
nonebot_plugin_htmlrender/utils/telemetry/prometheus.py,sha256=MLprW2A4anFJbJ9gmgawrrSQNDeYZmK4RS6TchHt5W4,6110
|
|
48
48
|
nonebot_plugin_htmlrender/utils/telemetry/sentry.py,sha256=8THXzRlSsyTLNAqcYcUhejcoJvm3oyNUvdGMWSJGbgY,7275
|
|
49
|
-
nonebot_plugin_htmlrender-0.7.
|
|
50
|
-
nonebot_plugin_htmlrender-0.7.
|
|
51
|
-
nonebot_plugin_htmlrender-0.7.
|
|
52
|
-
nonebot_plugin_htmlrender-0.7.
|
|
49
|
+
nonebot_plugin_htmlrender-0.7.2.dist-info/METADATA,sha256=mWsFk6HN7kHxYf9TArNZj8YfONNRQbV_MAjN-g72oW8,7108
|
|
50
|
+
nonebot_plugin_htmlrender-0.7.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
51
|
+
nonebot_plugin_htmlrender-0.7.2.dist-info/licenses/LICENSE,sha256=4HHgpu3ihnBZ9AVZDgOzGnAJRt8W7IQo5VSBEJKRr5g,1062
|
|
52
|
+
nonebot_plugin_htmlrender-0.7.2.dist-info/RECORD,,
|
|
File without changes
|