上一篇文章标题有一个 json 字典,结果报错了:

ERROR Process failed: _posts/微信公众号开发错误解决-发送模板消息.md
YAMLException: incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line at line 1, column 94:
     ... ot;:"data format error hint: [xrlw6a07614125]"} 发送模板消息 
                                         ^
    at generateError (/home/xxxxxxx/MyBlog/node_modules/js-yaml/lib/js-yaml/loader.js:167:10)
    at throwError (/home/xxxxxxx/MyBlog/node_modules/js-yaml/lib/js-yaml/loader.js:173:9)
    at readBlockMapping (/home/xxxxxxx/MyBlog/node_modules/js-yaml/lib/js-yaml/loader.js:1027:9)
    at composeNode (/home/xxxxxxx/MyBlog/node_modules/js-yaml/lib/js-yaml/loader.js:1359:12)
    at readDocument (/home/xxxxxxx/MyBlog/node_modules/js-yaml/lib/js-yaml/loader.js:1519:3)
    at loadDocuments (/home/xxxxxxx/MyBlog/node_modules/js-yaml/lib/js-yaml/loader.js:1575:5)
    at Object.load (/home/xxxxxxx/MyBlog/node_modules/js-yaml/lib/js-yaml/loader.js:1596:19)
    at parseYAML (/home/xxxxxxx/MyBlog/node_modules/hexo-front-matter/lib/front_matter.js:80:21)
    at parse (/home/xxxxxxx/MyBlog/node_modules/hexo-front-matter/lib/front_matter.js:56:12)
    at /home/xxxxxxx/MyBlog/node_modules/hexo/lib/plugins/processor/post.js:51:20
    at tryCatcher (/home/xxxxxxx/MyBlog/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/xxxxxxx/MyBlog/node_modules/bluebird/js/release/promise.js:509:35)
    at Promise._settlePromise (/home/xxxxxxx/MyBlog/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/xxxxxxx/MyBlog/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/xxxxxxx/MyBlog/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/home/xxxxxxx/MyBlog/node_modules/bluebird/js/release/promise.js:638:18)

搜了一些解决方法,大多说可以使用HTML字符实体代替,但是问题是我渲染出来的 html 页面里面这些字符实体不会转换成对应的字符而是保持了原样,所以这个方法并不可行

我的解决方法是:使用单引号把标题引起来
如这样就好了:

title: '微信公众号开发错误解决 {"errcode":47001,"errmsg":"data format error hint: \[xrlw6a07614125\]"} 发送模板消息'
categories:
  - 技术

附一些 HTML字符实体

" "
[ [
] ] 
{ { 
} } 
: :

这个地方有个列表但不全,例如冒号就没有。

这里更全。

欢迎来我的博客: https://codeplot.top/
我的博客hexo分类:https://codeplot.top/tags/hexo/


sxwxs
292 声望21 粉丝

计算机专业学生