nonebot-plugin-latex 0.0.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+ """
2
+ NoneBot2 LaTeX图形渲染插件
3
+ nonebot-plugin-latex
4
+
5
+ Copyright (c) 2024 金羿Eilles
6
+ nonebot-plugin-latex is licensed under Mulan PSL v2.
7
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
8
+ You may obtain a copy of Mulan PSL v2 at:
9
+ http://license.coscl.org.cn/MulanPSL2
10
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13
+ See the Mulan PSL v2 for more details.
14
+ """
15
+
16
+ from nonebot import get_plugin_config
17
+ from nonebot.plugin import PluginMetadata
18
+
19
+ from .config import Config
20
+ from .converter import converter
21
+
22
+ __version__ = "0.0.2"
23
+
24
+ __author__ = "Eilles"
25
+
26
+ __plugin_meta__ = PluginMetadata(
27
+ name="LaTeX图形渲染插件",
28
+ description="从互联网服务渲染LaTeX公式并发送",
29
+ usage="发送 latex 或 公式,后接内容或回复公式信息。",
30
+ type="application",
31
+ homepage="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai",
32
+ extra={"License": "Mulan PSL v2", "Author": __author__},
33
+ )
34
+
35
+
36
+ config = get_plugin_config(Config)
37
+
38
+
39
+ if config.enable_as_application:
40
+ from .main import *
@@ -0,0 +1,8 @@
1
+ from pydantic import BaseModel
2
+
3
+
4
+ class Config(BaseModel):
5
+ enable_as_application: bool = False
6
+ """
7
+ 是否启用应用逻辑:响应“latex”、“公式”指令
8
+ """
@@ -0,0 +1,6 @@
1
+ from .data import ConvertLatex
2
+
3
+ converter = ConvertLatex()
4
+ """
5
+ Latex 渲染器
6
+ """
@@ -0,0 +1,314 @@
1
+ """
2
+ 数据类
3
+
4
+
5
+ Copyright (c) 2024 金羿Eilles
6
+ nonebot-plugin-latex is licensed under Mulan PSL v2.
7
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
8
+ You may obtain a copy of Mulan PSL v2 at:
9
+ http://license.coscl.org.cn/MulanPSL2
10
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13
+ See the Mulan PSL v2 for more details.
14
+ """
15
+
16
+ from typing import Optional, Literal, Tuple
17
+ import httpx
18
+ import time
19
+ import re
20
+
21
+
22
+ class ConvertChannel:
23
+ URL: str
24
+
25
+ async def get_to_convert(
26
+ self,
27
+ latex_code: str,
28
+ dpi: int = 600,
29
+ fgcolour: str = "000000",
30
+ timeout: int = 5,
31
+ retry: int = 3,
32
+ ) -> Tuple[Literal[True], bytes] | Tuple[Literal[False], bytes | str]:
33
+ return False, "请勿直接调用母类"
34
+
35
+ @staticmethod
36
+ def channel_test() -> int:
37
+ return -1
38
+
39
+
40
+ class L2PChannel(ConvertChannel):
41
+
42
+ URL = "https://www.latex2png.com"
43
+
44
+ async def get_to_convert(
45
+ self,
46
+ latex_code: str,
47
+ dpi: int = 600,
48
+ fgcolour: str = "000000",
49
+ timeout: int = 5,
50
+ retry: int = 3,
51
+ ) -> Tuple[Literal[True], bytes] | Tuple[Literal[False], bytes | str]:
52
+
53
+ async with httpx.AsyncClient(
54
+ timeout=timeout,
55
+ ) as client:
56
+ while retry > 0:
57
+ try:
58
+ post_response = await client.post(
59
+ self.URL + "/api/convert",
60
+ json={
61
+ "auth": {"user": "guest", "password": "guest"},
62
+ "latex": latex_code,
63
+ "resolution": dpi,
64
+ "color": fgcolour,
65
+ },
66
+ )
67
+ if post_response.status_code == 200:
68
+
69
+ if (json_response := post_response.json())[
70
+ "result-message"
71
+ ] == "success":
72
+
73
+ # print("latex2png:", post_response.content)
74
+
75
+ if (
76
+ get_response := await client.get(
77
+ self.URL + json_response["url"]
78
+ )
79
+ ).status_code == 200:
80
+ return True, get_response.content
81
+ else:
82
+ return False, json_response["result-message"]
83
+ retry -= 1
84
+ except httpx.TimeoutException:
85
+ retry -= 1
86
+ raise ConnectionError("服务不可用")
87
+ return False, "未知错误"
88
+
89
+ @staticmethod
90
+ def channel_test() -> int:
91
+ with httpx.Client(timeout=5) as client:
92
+ try:
93
+ start_time = time.time_ns()
94
+ latex2png = (
95
+ client.get(
96
+ "https://www.latex2png.com{}"
97
+ + client.post(
98
+ "https://www.latex2png.com/api/convert",
99
+ json={
100
+ "auth": {"user": "guest", "password": "guest"},
101
+ "latex": "\\\\int_{a}^{b} x^2 \\\\, dx = \\\\frac{b^3}{3} - \\\\frac{a^3}{5}\n",
102
+ "resolution": 600,
103
+ "color": "000000",
104
+ },
105
+ ).json()["url"]
106
+ ),
107
+ time.time_ns() - start_time,
108
+ )
109
+ except:
110
+ return 99999
111
+ if latex2png[0].status_code == 200:
112
+ return latex2png[1]
113
+ else:
114
+ return 99999
115
+
116
+
117
+ class CDCChannel(ConvertChannel):
118
+
119
+ URL = "https://latex.codecogs.com"
120
+
121
+ async def get_to_convert(
122
+ self,
123
+ latex_code: str,
124
+ dpi: int = 600,
125
+ fgcolour: str = "000000",
126
+ timeout: int = 5,
127
+ retry: int = 3,
128
+ ) -> Tuple[Literal[True], bytes] | Tuple[Literal[False], bytes | str]:
129
+ async with httpx.AsyncClient(
130
+ timeout=timeout,
131
+ ) as client:
132
+
133
+ while retry > 0:
134
+ try:
135
+ response = await client.get(
136
+ self.URL
137
+ + r"/png.image?\huge&space;\dpi{"
138
+ + str(dpi)
139
+ + r"}\fg{"
140
+ + fgcolour
141
+ + r"}"
142
+ + latex_code
143
+ )
144
+ # print("codecogs:", response)
145
+ if response.status_code == 200:
146
+ return True, response.content
147
+ else:
148
+ return False, response.content
149
+ retry -= 1
150
+ except httpx.TimeoutException:
151
+ retry -= 1
152
+ return False, "未知错误"
153
+
154
+ @staticmethod
155
+ def channel_test() -> int:
156
+ with httpx.Client(timeout=5) as client:
157
+ try:
158
+ start_time = time.time_ns()
159
+ codecogs = (
160
+ client.get(
161
+ r"https://latex.codecogs.com/png.image?\huge%20\dpi{600}\\int_{a}^{b}x^2\\,dx=\\frac{b^3}{3}-\\frac{a^3}{5}"
162
+ ),
163
+ time.time_ns() - start_time,
164
+ )
165
+ except:
166
+ return 99999
167
+ if codecogs[0].status_code == 200:
168
+ return codecogs[1]
169
+ else:
170
+ return 99999
171
+
172
+
173
+ class JRTChannel(ConvertChannel):
174
+
175
+ URL = "https://latex2image.joeraut.com"
176
+
177
+ async def get_to_convert(
178
+ self,
179
+ latex_code: str,
180
+ dpi: int = 600,
181
+ fgcolour: str = "000000", # 无效设置
182
+ timeout: int = 5,
183
+ retry: int = 3,
184
+ ) -> Tuple[Literal[True], bytes] | Tuple[Literal[False], bytes | str]:
185
+
186
+ async with httpx.AsyncClient(
187
+ timeout=timeout,
188
+ ) as client:
189
+ while retry > 0:
190
+ try:
191
+ post_response = await client.post(
192
+ self.URL + "/default/latex2image",
193
+ json={
194
+ "latexInput": latex_code,
195
+ "outputFormat": "PNG",
196
+ "outputScale": "{}%".format(dpi / 3 * 5),
197
+ },
198
+ )
199
+ print(post_response)
200
+ if post_response.status_code == 200:
201
+
202
+ if not (json_response := post_response.json())["error"]:
203
+
204
+ # print("latex2png:", post_response.content)
205
+
206
+ if (
207
+ get_response := await client.get(
208
+ json_response["imageUrl"]
209
+ )
210
+ ).status_code == 200:
211
+ return True, get_response.content
212
+ else:
213
+ return False, json_response["error"]
214
+ retry -= 1
215
+ except httpx.TimeoutException:
216
+ retry -= 1
217
+ raise ConnectionError("服务不可用")
218
+ return False, "未知错误"
219
+
220
+ @staticmethod
221
+ def channel_test() -> int:
222
+ with httpx.Client(timeout=5) as client:
223
+ try:
224
+ start_time = time.time_ns()
225
+ joeraut = (
226
+ client.get(
227
+ client.post(
228
+ "https://www.latex2png.com/api/convert",
229
+ json={
230
+ "latexInput": "\\\\int_{a}^{b} x^2 \\\\, dx = \\\\frac{b^3}{3} - \\\\frac{a^3}{5}",
231
+ "outputFormat": "PNG",
232
+ "outputScale": "1000%",
233
+ },
234
+ ).json()["imageUrl"]
235
+ ),
236
+ time.time_ns() - start_time,
237
+ )
238
+ except:
239
+ return 99999
240
+ if joeraut[0].status_code == 200:
241
+ return joeraut[1]
242
+ else:
243
+ return 99999
244
+
245
+
246
+ CHANNEL_LIST: list[type[ConvertChannel]] = [L2PChannel, CDCChannel, JRTChannel]
247
+
248
+
249
+ class ConvertLatex:
250
+
251
+ channel: ConvertChannel
252
+
253
+ def __init__(self, channel: Optional[ConvertChannel] = None) -> None:
254
+ """
255
+ LaTeX在线渲染类
256
+
257
+ Args:
258
+ channel (Optional[ConvertChannel], optional):
259
+ 选择何种在线转换通道,若为空,则自动选择延迟最低的通道。默认为空。
260
+ [WARNING] 请注意!选择通道时采取的是同步函数,因此可能造成阻塞。
261
+ """
262
+
263
+ if channel is None:
264
+ self.channel = self.auto_choose_channel()
265
+ else:
266
+ self.channel = channel
267
+
268
+ async def generate_png(
269
+ self,
270
+ latex: str,
271
+ dpi: int = 600,
272
+ foreground_colour: str = "000000",
273
+ timeout_: int = 5,
274
+ retry_: int = 3,
275
+ ) -> Tuple[Literal[True], bytes] | Tuple[Literal[False], bytes | str]:
276
+ """
277
+ LaTeX 在线渲染
278
+
279
+ 参数
280
+ ====
281
+
282
+ latex: str
283
+ LaTeX 代码
284
+ dpi: int
285
+ 分辨率
286
+ foreground_colour: str
287
+ 文字前景色
288
+ timeout_: int
289
+ 超时时间
290
+ retry_: int
291
+ 重试次数
292
+ 返回
293
+ ====
294
+ bytes
295
+ 图片
296
+ """
297
+ return await self.channel.get_to_convert(
298
+ latex, dpi, foreground_colour, timeout_, retry_
299
+ )
300
+
301
+ @staticmethod
302
+ def auto_choose_channel() -> ConvertChannel:
303
+
304
+ return min(
305
+ CHANNEL_LIST,
306
+ key=lambda channel: channel.channel_test(),
307
+ )()
308
+
309
+
310
+ # 正则匹配 LaTeX 公式内容
311
+ LATEX_PATTERN = re.compile(
312
+ r"\\begin\{equation\}(.*?)\\end\{equation\}|(?<!\$)(\$(.*?)\$|\$\$(.*?)\$\$|\\\[(.*?)\\\]|\\\[.*?\\\]|\\\((.*?)\\\))",
313
+ re.DOTALL,
314
+ )
@@ -0,0 +1,121 @@
1
+ """
2
+ 命令功能集
3
+
4
+
5
+ Copyright (c) 2024 金羿Eilles
6
+ nonebot-plugin-latex is licensed under Mulan PSL v2.
7
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
8
+ You may obtain a copy of Mulan PSL v2 at:
9
+ http://license.coscl.org.cn/MulanPSL2
10
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13
+ See the Mulan PSL v2 for more details.
14
+ """
15
+
16
+ import nonebot
17
+ from nonebot.adapters.onebot.v11 import MessageEvent
18
+
19
+
20
+ # from nonebot.matcher import Matcher
21
+
22
+ nonebot.require("nonebot_plugin_alconna")
23
+
24
+ # from nonebot_plugin_alconna.util import annotation
25
+ from nonebot_plugin_alconna import (
26
+ Image as Alconna_Image,
27
+ Text as Alconnna_Text,
28
+ UniMessage,
29
+ )
30
+
31
+ from .data import LATEX_PATTERN
32
+ from .converter import converter
33
+
34
+ command_heads = (
35
+ "latex",
36
+ "公式",
37
+ "数学公式",
38
+ "latex公式",
39
+ "latex_formula",
40
+ "latex_math",
41
+ "公式渲染",
42
+ "latex渲染",
43
+ )
44
+ """
45
+ 命令头
46
+ """
47
+
48
+
49
+ async def check_for_scan(
50
+ event: MessageEvent,
51
+ # state: T_State,
52
+ ) -> bool:
53
+ """
54
+ 检查是否为扫码指令
55
+ """
56
+
57
+ # print("检查消息满足扫码要求:", event)
58
+ if isinstance(event, MessageEvent):
59
+ # print("此为原始信息:", event.raw_message)
60
+ # event.message
61
+ for msg in event.message:
62
+ # print("这是其中一个信息---", msg)
63
+ if msg.type == "text" and (msgdata := msg.data["text"].strip()):
64
+ if msgdata.startswith(command_heads):
65
+
66
+ # print("判断:这确实是指令发出")
67
+ return True
68
+ else:
69
+ # print("判断:这不是指令")
70
+ return False
71
+ return False
72
+
73
+
74
+ scan = nonebot.on_message(
75
+ rule=check_for_scan,
76
+ block=False,
77
+ priority=90,
78
+ )
79
+
80
+
81
+ @scan.handle()
82
+ async def handle_pic(
83
+ event: MessageEvent,
84
+ # state: T_State,
85
+ # arg: Optional[Message] = CommandArg(),
86
+ ):
87
+ # print("正在解决reply指令……")
88
+ latexes = []
89
+ if event.reply:
90
+ latexes.extend(LATEX_PATTERN.finditer(event.reply.message.extract_plain_text()))
91
+
92
+ # print(arg)
93
+ if event.message:
94
+ latexes.extend(LATEX_PATTERN.finditer(event.message.extract_plain_text()))
95
+
96
+ if not latexes:
97
+ await scan.finish(
98
+ "同志!以我们目前的实力,暂时无法读取你大脑中的公式,你还是把它通过你的输入设备打出来吧。"
99
+ )
100
+ return
101
+
102
+ result_msg = UniMessage()
103
+
104
+ for tex_macher in latexes:
105
+ tex = tex_macher.group().replace("$", "")
106
+ if (result := await converter.generate_png(tex))[0]:
107
+ result_msg.append(
108
+ Alconna_Image(raw=result[1], mimetype="image/png", name="latex.png") # type: ignore
109
+ )
110
+ else:
111
+ if isinstance(result[1], str):
112
+ result_msg.append(
113
+ Alconnna_Text("无法渲染${}$:{}".format(tex, result[1]))
114
+ )
115
+ else:
116
+ result_msg.append(Alconnna_Text("无法渲染${}$".format(tex)))
117
+ result_msg.append(
118
+ Alconna_Image(raw=result[1], mimetype="image/png", name="error.png")
119
+ )
120
+
121
+ await result_msg.send(reply_to=True)
@@ -0,0 +1,128 @@
1
+ 木兰宽松许可证, 第2版
2
+
3
+ 木兰宽松许可证, 第2版
4
+ 2020年1月 http://license.coscl.org.cn/MulanPSL2
5
+
6
+ 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
7
+
8
+ 0. 定义
9
+
10
+ “软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
11
+
12
+ “贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
13
+
14
+ “贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
15
+
16
+ “法人实体” 是指提交贡献的机构及其“关联实体”。
17
+
18
+ “关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
19
+
20
+ 1. 授予版权许可
21
+
22
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
23
+
24
+ 2. 授予专利许可
25
+
26
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
27
+
28
+ 3. 无商标许可
29
+
30
+ “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
31
+
32
+ 4. 分发限制
33
+
34
+ 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
35
+
36
+ 5. 免责声明与责任限制
37
+
38
+ “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
39
+
40
+ 6. 语言
41
+
42
+ “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
43
+
44
+ 条款结束
45
+
46
+ 如何将木兰宽松许可证,第2版,应用到您的软件
47
+
48
+ 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
49
+
50
+ 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
51
+
52
+ 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
53
+
54
+ 3, 请将如下声明文本放入每个源文件的头部注释中。
55
+
56
+ Copyright (c) [Year] [name of copyright holder]
57
+ [Software Name] is licensed under Mulan PSL v2.
58
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
59
+ You may obtain a copy of Mulan PSL v2 at:
60
+ http://license.coscl.org.cn/MulanPSL2
61
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
62
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
63
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
64
+ See the Mulan PSL v2 for more details.
65
+
66
+
67
+ Mulan Permissive Software License,Version 2
68
+
69
+ Mulan Permissive Software License,Version 2 (Mulan PSL v2)
70
+ January 2020 http://license.coscl.org.cn/MulanPSL2
71
+
72
+ Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
73
+
74
+ 0. Definition
75
+
76
+ Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
77
+
78
+ Contribution means the copyrightable work licensed by a particular Contributor under this License.
79
+
80
+ Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
81
+
82
+ Legal Entity means the entity making a Contribution and all its Affiliates.
83
+
84
+ Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
85
+
86
+ 1. Grant of Copyright License
87
+
88
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
89
+
90
+ 2. Grant of Patent License
91
+
92
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
93
+
94
+ 3. No Trademark License
95
+
96
+ No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
97
+
98
+ 4. Distribution Restriction
99
+
100
+ You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
101
+
102
+ 5. Disclaimer of Warranty and Limitation of Liability
103
+
104
+ THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
105
+
106
+ 6. Language
107
+
108
+ THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
109
+
110
+ END OF THE TERMS AND CONDITIONS
111
+
112
+ How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
113
+
114
+ To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
115
+
116
+ Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
117
+ Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package;
118
+ Attach the statement to the appropriate annotated syntax at the beginning of each source file.
119
+
120
+ Copyright (c) [Year] [name of copyright holder]
121
+ [Software Name] is licensed under Mulan PSL v2.
122
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
123
+ You may obtain a copy of Mulan PSL v2 at:
124
+ http://license.coscl.org.cn/MulanPSL2
125
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
126
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
127
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
128
+ See the Mulan PSL v2 for more details.
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.2
2
+ Name: nonebot-plugin-latex
3
+ Version: 0.0.2
4
+ Summary: 通过互联网公共服务渲染LaTeX公式
5
+ Author-email: Eilles <EillesWan@outlook.com>
6
+ License: 木兰宽松许可证, 第2版
7
+
8
+ 木兰宽松许可证, 第2版
9
+ 2020年1月 http://license.coscl.org.cn/MulanPSL2
10
+
11
+ 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
12
+
13
+ 0. 定义
14
+
15
+ “软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
16
+
17
+ “贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
18
+
19
+ “贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
20
+
21
+ “法人实体” 是指提交贡献的机构及其“关联实体”。
22
+
23
+ “关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
24
+
25
+ 1. 授予版权许可
26
+
27
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
28
+
29
+ 2. 授予专利许可
30
+
31
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
32
+
33
+ 3. 无商标许可
34
+
35
+ “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
36
+
37
+ 4. 分发限制
38
+
39
+ 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
40
+
41
+ 5. 免责声明与责任限制
42
+
43
+ “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
44
+
45
+ 6. 语言
46
+
47
+ “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
48
+
49
+ 条款结束
50
+
51
+ 如何将木兰宽松许可证,第2版,应用到您的软件
52
+
53
+ 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
54
+
55
+ 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
56
+
57
+ 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
58
+
59
+ 3, 请将如下声明文本放入每个源文件的头部注释中。
60
+
61
+ Copyright (c) [Year] [name of copyright holder]
62
+ [Software Name] is licensed under Mulan PSL v2.
63
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
64
+ You may obtain a copy of Mulan PSL v2 at:
65
+ http://license.coscl.org.cn/MulanPSL2
66
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
67
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
68
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
69
+ See the Mulan PSL v2 for more details.
70
+
71
+
72
+ Mulan Permissive Software License,Version 2
73
+
74
+ Mulan Permissive Software License,Version 2 (Mulan PSL v2)
75
+ January 2020 http://license.coscl.org.cn/MulanPSL2
76
+
77
+ Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
78
+
79
+ 0. Definition
80
+
81
+ Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
82
+
83
+ Contribution means the copyrightable work licensed by a particular Contributor under this License.
84
+
85
+ Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
86
+
87
+ Legal Entity means the entity making a Contribution and all its Affiliates.
88
+
89
+ Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
90
+
91
+ 1. Grant of Copyright License
92
+
93
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
94
+
95
+ 2. Grant of Patent License
96
+
97
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
98
+
99
+ 3. No Trademark License
100
+
101
+ No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
102
+
103
+ 4. Distribution Restriction
104
+
105
+ You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
106
+
107
+ 5. Disclaimer of Warranty and Limitation of Liability
108
+
109
+ THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
110
+
111
+ 6. Language
112
+
113
+ THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
114
+
115
+ END OF THE TERMS AND CONDITIONS
116
+
117
+ How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
118
+
119
+ To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
120
+
121
+ Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
122
+ Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package;
123
+ Attach the statement to the appropriate annotated syntax at the beginning of each source file.
124
+
125
+ Copyright (c) [Year] [name of copyright holder]
126
+ [Software Name] is licensed under Mulan PSL v2.
127
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
128
+ You may obtain a copy of Mulan PSL v2 at:
129
+ http://license.coscl.org.cn/MulanPSL2
130
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
131
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
132
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
133
+ See the Mulan PSL v2 for more details.
134
+ Project-URL: Homepage, https://github.com/EillesWan/nonebot-plugin-latex
135
+ Project-URL: Bug Tracker, https://github.com/EillesWan/nonebot-plugin-latex/issues
136
+ Requires-Python: <4.0,>=3.9
137
+ Description-Content-Type: text/markdown
138
+ License-File: LICENSE
139
+ Requires-Dist: playwright>=1.17.2
140
+ Requires-Dist: nonebot2>=2.2.0
141
+ Requires-Dist: jinja2>=3.0.3
142
+ Requires-Dist: markdown>=3.3.6
143
+ Requires-Dist: Pygments>=2.10.0
144
+ Requires-Dist: python-markdown-math>=0.8
145
+ Requires-Dist: pymdown-extensions>=9.1
146
+ Requires-Dist: aiofiles>=0.8.0
147
+
148
+ # nonebot-plugin-latex
149
+ NoneBot2 LaTeX图形渲染插件
150
+
151
+ 通过互联网公共服务渲染LaTeX公式
152
+
153
+ 利用 www.latex2png.com 和 latex.codecogs.com 在线渲染 LaTeX 公式
154
+
155
+ ## 安装
156
+
157
+ pip install nonebot-plugin-latex
158
+
159
+ ## 使用
160
+
161
+ 如果希望直接作为 LaTeX 渲染插件使用的话,请在 NoneBot 配置文件中添加以下内容:
162
+
163
+ ```env
164
+ enable_as_application = true
165
+ ```
166
+
167
+ 这样就可以使用 `latex` 命令进行渲染了,例如 `latex E=mc^2` 就会返回这个方程式的渲染图片。
@@ -0,0 +1,10 @@
1
+ nonebot_plugin_latex/__init__.py,sha256=xtRmHTHv3UgYiyxpq_HDH4-uzn-DQXU2D6YxvpuwmHs,1259
2
+ nonebot_plugin_latex/config.py,sha256=HSMYcxZ-6jfX0b8ZYavLpcXPEz2uC-d9716UE_vtUhE,192
3
+ nonebot_plugin_latex/converter.py,sha256=08RmFCBrUda8PlnqazX71aHjntBzlSOJc_ZeUHfMQ_M,89
4
+ nonebot_plugin_latex/data.py,sha256=j2tnJSsBM1iy_ogzSsXNZr0mh64qGIuTLzWO0weIKZc,10434
5
+ nonebot_plugin_latex/main.py,sha256=cHSobOtivGNfrfSBFQmIDoK4FiRpRbF0mo1fSBV3xUk,3511
6
+ nonebot_plugin_latex-0.0.2.dist-info/LICENSE,sha256=ISc-fUbtRp39lxd4MpdVr2Saz7XF2yik0RTSRNuhlaM,9375
7
+ nonebot_plugin_latex-0.0.2.dist-info/METADATA,sha256=TR7yDjCYcQWH5FBgmGW5zjDIjQ8uhMFQUL4ljOsdlkE,11627
8
+ nonebot_plugin_latex-0.0.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
+ nonebot_plugin_latex-0.0.2.dist-info/top_level.txt,sha256=AEtxXrscUdkhTvgg--hAE9WRsW0QVttzK2H-fI9xbGs,21
10
+ nonebot_plugin_latex-0.0.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ nonebot_plugin_latex