Hexo支持Flowchart

首先安装支持库1

1
npm install hexo-diagram --save

可能会出现问题:

1
npm WARN deprecated phantom@0.7.2: v1 is no longer maintained, please upgrade to v2.0+ as soon possible.

导致运行时出现问题:

1
2
3
4
5
hexo s
Hexo Diagram Filter
{ diagramFolder: '/Users/luohanjie/Documents/Dropbox/Blogs/source/diagrams' }
Generate: [flow]Robotics/SCARA型机械臂工作区域边界计算方法-diagram-0.png
phantomjs-node: You don't have 'phantomjs' installed

解决方向: 安装最新版phantomjs

1
npm install phantomjs -g

但是运行时可能会出网络问题:

1
phantom stdout: NETWORK_ERR: XMLHttpRequest Exception 101: A network error occurred in synchronous requests.

可以通过关闭web-security解决2。将node_modules/hexo-diagram/generators/factory/phantom.js部分代码修改为:

1
2
3
4
options = { 'web-security': 'no' };

return function (type, code, output, callback) {
phantom.create({parameters: options}, function (ph) {

问题解决。


  1. https://www.npmjs.com/package/hexo-diagram↩︎

  2. https://github.com/amir20/phantomjs-node/issues/345↩︎