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

图片如果是html标签插入的无法迁移 #45

Closed
singledoggy opened this issue Jan 23, 2022 · 7 comments
Closed

图片如果是html标签插入的无法迁移 #45

singledoggy opened this issue Jan 23, 2022 · 7 comments
Labels

Comments

@singledoggy
Copy link

因为用html标签插入图片可以比较方便的配置大小,e.g.:

<img src="./xxx.png" width = "300" height = "200" alt="图片名称" align=center />

能否考虑添加对标签的支持

@Molunerfinn
Copy link
Member

可以,后续会考虑支持

@singledoggy
Copy link
Author

针对我自己的标签目前我是用简单的正则替换成markdown格式再进行后处理的,这是一个最小化的例子,可能不能覆盖所有的标签情况

import re
a='<img src="./xxx.png" width = "300" height = "200" alt="图片名称" align=center />'
pic_url = re.compile('(<img src=")(.*?)(".*)(>)')
a=re.sub(pic_url,r"![](\2)",a)

@Molunerfinn
Copy link
Member

单纯的正则匹配会遇到很多边界case。这边打算引入markdown的parser来处理,比如 marked,通过AST的方式来实现

@Molunerfinn
Copy link
Member

这个预计会在1.3.0版本里做支持,因为对底层实现是个非常大的改动

@Molunerfinn
Copy link
Member

看了一下markdown的AST实现,对于img标签的处理也都是处理成 html 节点。- -所以还是要用正则匹配。我处理一下

@singledoggy
Copy link
Author

感谢开发和维护!

@Molunerfinn
Copy link
Member

v1.3.0已经支持,请配合最新的PicGo或者PicGo-Core版本使用

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

No branches or pull requests

2 participants