Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Markdown Support. #188

Merged
merged 13 commits into from
Feb 24, 2023
Merged

Conversation

Hakureirm
Copy link
Contributor

This PR includes changes to add Markdown support to 'text_to_img.py' and update the Dockerfile, as well as changes to the apt installation file and pip requirements file and font files. All changes have been successfully tested in Docker.

utils/text_to_img.py Outdated Show resolved Hide resolved
utils/text_to_img.py Outdated Show resolved Hide resolved
utils/markdown_support_template.html Outdated Show resolved Hide resolved
Dockerfile Show resolved Hide resolved
@lss233
Copy link
Owner

lss233 commented Feb 23, 2023

在 Windows 下启动出现如下报错:
关联 issue: Python-Markdown/markdown#1132

D:\quickstart-windows-amd64\chatgpt\python3.9\python.exe D:\quickstart-windows-amd64\chatgpt-mirai-qq-bot\bot.py 
Traceback (most recent call last):
  File "D:\quickstart-windows-amd64\chatgpt-mirai-qq-bot\bot.py", line 26, in <module>
    from utils.text_to_img import to_image
  File "D:\quickstart-windows-amd64\chatgpt-mirai-qq-bot\utils\text_to_img.py", line 6, in <module>
    import markdown
  File "D:\quickstart-windows-amd64\chatgpt\python3.9\lib\site-packages\markdown\__init__.py", line 22, in <module>
    from .core import Markdown, markdown, markdownFromFile
  File "D:\quickstart-windows-amd64\chatgpt\python3.9\lib\site-packages\markdown\core.py", line 27, in <module>
    from .preprocessors import build_preprocessors
  File "D:\quickstart-windows-amd64\chatgpt\python3.9\lib\site-packages\markdown\preprocessors.py", line 29, in <module>
    from .htmlparser import HTMLExtractor
  File "D:\quickstart-windows-amd64\chatgpt\python3.9\lib\site-packages\markdown\htmlparser.py", line 31, in <module>
    spec.loader.exec_module(htmlparser)
AttributeError: 'zipimporter' object has no attribute 'exec_module'
2023-02-24 01:12:44.213 | INFO     | chatbot:conversation_remover:101 - 删除会话中……

Process finished with exit code 1

已修复。

@acai66
Copy link
Contributor

acai66 commented Feb 24, 2023

询问markdown语法时,有这一段图片样例,在渲染为html时报错:提示图片URL加载失败
image

@acai66
Copy link
Contributor

acai66 commented Feb 24, 2023

保险起见,又加入了之前的text_to_image函数,在markdown渲染失败时,调用之前的文本转图片函数。
image

@lss233
Copy link
Owner

lss233 commented Feb 24, 2023

保险起见,又加入了之前的text_to_image函数,在markdown渲染失败时,调用之前的文本转图片函数。 image

我觉得这样很不错

@acai66
Copy link
Contributor

acai66 commented Feb 24, 2023

供参考,不提pr
text_to_img.zip

@lss233
Copy link
Owner

lss233 commented Feb 24, 2023

供参考,不提pr text_to_img.zip

好的,那就由我来进行一个合并

@lss233
Copy link
Owner

lss233 commented Feb 24, 2023

搞定了,感谢两位

@lss233 lss233 merged commit 4667da1 into lss233:browser-version Feb 24, 2023
@acai66
Copy link
Contributor

acai66 commented Feb 24, 2023

不清楚你们有没有单行代码过长被截断的情况
4ea5213713078d87

@Hakureirm
Copy link
Contributor Author

不清楚你们有没有单行代码过长被截断的情况 4ea5213713078d87

出现过。代码块应该是可以改成超出原设定宽度后,自适应宽度的,之前测试它自己渲染来自URL的图片时就自动做到了,不过我没学过前端,不知道具体是改哪里。

@lss233
Copy link
Owner

lss233 commented Feb 24, 2023

这个开个 issue 跟一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants