Data Science, Machine Learning, Fullstack Web Developer.
- Read more about my Blog
- Talk with me by Email: [email protected]
🍰 Hexo local image plugin. | Hexo 本地图片插件: 转换 图片相对路径 为 asset_img
License: MIT License
Data Science, Machine Learning, Fullstack Web Developer.
写了个在线测试例子,方便测试,起到单元测试的效果,可以在线运行
fork本仓库,修改fork后的代码,使用下方安装,注意替换你自己的用户名
npm install git://github.com/yiyungent/hexo-asset-img.git#main
Line 19 in a981f1b
如果图片路径有空格,比如 ![](t a/a.png)
,在markdown中需要encode空格,就变成了 ![](t%20a/a.png)
。这时候就会匹配失败,导致没法替换成功。
个人试着修改了下,简单的改成
// ![example](postname/example.jpg) --> {% asset_img example.jpg example %}
var regExp = RegExp("!\\[+?(.*?)\\]+?\\((" + fileName + "|" + fileName.replace(" ", "%20") + ')/(.+?)\\)', "g");
// hexo g
data.content = data.content.replace(regExp, "{% asset_img $3 $1 %}","g");
是可以成功的,希望作者能完善下这个的匹配。
ERROR Plugin load failed: hexo-asset-img
TypeError: require(...) is not a function
at C:\path\to\dir\node_modules\hexo-asset-img\index.js:1:97
at C:\path\to\dir\node_modules\hexo\dist\hexo\index.js:248:20
at tryCatcher (C:\path\to\dir\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\path\to\dir\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (C:\path\to\dir\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (C:\path\to\dir\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (C:\path\to\dir\node_modules\bluebird\js\release\promise.js:729:18)
at _drainQueueStep (C:\path\to\dir\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (C:\path\to\dir\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (C:\path\to\dir\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (C:\path\to\dir\node_modules\bluebird\js\release\async.js:15:14)
at processImmediate (node:internal/timers:466:21)
[email protected]
├── @next-theme/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
研究了一下是因为7.0.0的hexo升级了hexo-log组件,有了新的用法,需要使用 const log = require('hexo-log').default({ 'debug': false, 'slient': false });
如 ![git](<fileName/2023-11-28-15-54-23.png>)
就不会匹配到
解决方案:
第50行的
var regExp = RegExp("!\\[(.*?)\\]\\(" + fileName + '/(.+?)\\)', "g");
改为
var regExp = RegExp("!\\[(.*?)\\]\\(<?" + fileName + '/(.+?)>?\\)', "g");
![1](test/1.png)
<img src="/test/img-1.png" class="" width="1">
匹配错误
猜测:
![这里纯数字时错误](xxx)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.