Comments (5)
然后我再测试发现,文件里有空格,也是有问题。需要改下最后的匹配格式,但如果文件名本身就有%20
,那么也会问题。但这个的概率感觉比空格的概率低。
data.content = data.content.replace(regExp, function(matchStr, group1, group2, group3){
var imgname = group3.replace("%20", " ");
return `{% asset_img "${imgname}" "${group1}" %}`;
}, "g");
from hexo-asset-img.
收到,感谢你的贡献!最近比较忙(电脑都用不上),等下次有时间我再来更新下(好奇怪,我居然没收到这个issue通知),其实你可以直接pull request,然后我自己合并也行
from hexo-asset-img.
收到,感谢你的贡献!最近比较忙(电脑都用不上),等下次有时间我再来更新下(好奇怪,我居然没收到这个issue通知),其实你可以直接pull request,然后我自己合并也行
呃主要是我不是搞js的,代码不多大致看得懂流程才学了下语法,就改了下,pr就不提了,等你后面修改吧。
from hexo-asset-img.
文件名里面有特殊符号都会有问题
根据https://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript的建议
文件名用escapeRegex处理一下就可以解决问题了
function escapeRegex(string) {
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
from hexo-asset-img.
然后我再测试发现,文件里有空格,也是有问题。需要改下最后的匹配格式,但如果文件名本身就有
%20
,那么也会问题。但这个的概率感觉比空格的概率低。data.content = data.content.replace(regExp, function(matchStr, group1, group2, group3){ var imgname = group3.replace("%20", " "); return `{% asset_img "${imgname}" "${group1}" %}`; }, "g");
今天想起来写了个在线测试 demo (懒癌晚期),这个写法不行啊
https://replit.com/@yiyungent/hexo-asset-img-test#index.js
from hexo-asset-img.
Related Issues (7)
- ![1](test/1.png) 匹配错误 导致 图片宽度为1 HOT 3
- 在线运行测试地址
- 能不能不要转换文本中的md格式? HOT 2
- 【自己解决bug】自己修改代码,npm安装自己仓库 方案 HOT 1
- [email protected] 生成时报错 HOT 1
- [bug] 不能匹配图片链接中两头带 <> 的,附解决方案 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hexo-asset-img.