ele828 / hexo-prism-plugin

Hexo plugin for code highlighting by prism.js, supporting JSX syntax
205 stars 51 forks source link

无法加载prism #27

Closed OhYee closed 6 years ago

OhYee commented 7 years ago

安装之后,关闭hexo默认highlight,报错

highlight:
  enable: false

错误信息如下:

Template render error: (unknown path) [Line 49, Column 23]
  expected variable end
    at Object.exports.prettifyError (D:\Portable\Code\Blog\node_modules\nunjucks\src\lib.js:34:15)
    at new_cls.render (D:\Portable\Code\Blog\node_modules\nunjucks\src\environment.js:469:27)
    at new_cls.renderString (D:\Portable\Code\Blog\node_modules\nunjucks\src\environment.js:327:21)
    at D:\Portable\Code\Blog\node_modules\hexo\lib\extend\tag.js:66:9
    at Promise._execute (D:\Portable\Code\Blog\node_modules\bluebird\js\release\debuggability.js:300:9)
    at Promise._resolveFromExecutor (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:483:18)
    at new Promise (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:79:10)
    at Tag.render (D:\Portable\Code\Blog\node_modules\hexo\lib\extend\tag.js:64:10)
    at Object.tagFilter [as onRenderEnd] (D:\Portable\Code\Blog\node_modules\hexo\lib\hexo\post.js:266:16)
    at D:\Portable\Code\Blog\node_modules\hexo\lib\hexo\render.js:65:19
    at tryCatcher (D:\Portable\Code\Blog\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:693:18)
    at Async._drainQueue (D:\Portable\Code\Blog\node_modules\bluebird\js\release\async.js:133:16)
    at Async._drainQueues (D:\Portable\Code\Blog\node_modules\bluebird\js\release\async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (D:\Portable\Code\Blog\node_modules\bluebird\js\release\async.js:17:14)
    at runCallback (timers.js:781:20)
    at tryOnImmediate (timers.js:743:5)
    at processImmediate [as _immediateCallback] (timers.js:714:5)

打开默认highlight,代码块无高亮

node version: v8.2.1 npm version: 5.3.0 hexo version: hexo: 3.3.8 hexo-cli: 1.0.3 os: Windows_NT 10.0.15063 win32 x64 http_parser: 2.7.0 node: 8.2.1 v8: 5.8.283.41 uv: 1.13.1 zlib: 1.2.11 ares: 1.10.1-DEV modules: 57 openssl: 1.0.2l icu: 59.1 unicode: 9.0 cldr: 31.0.1 tz: 2017b

hexo-prism-plugin 已按照要求安装,_config未添加指定配置项会提示

ERROR Plugin load failed: hexo-prism-plugin
Error: `prism_plugin` options should be added to _config.yml file
    at D:\Portable\Code\Blog\node_modules\hexo-prism-plugin\src\index.js:70:9
    at D:\Portable\Code\Blog\node_modules\hexo\lib\hexo\index.js:232:12
    at tryCatcher (D:\Portable\Code\Blog\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:693:18)
    at Promise._fulfill (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:638:18)
    at Promise._resolveCallback (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:432:57)
    at Promise._settlePromiseFromHandler (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:524:17)
    at Promise._settlePromise (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:693:18)
    at Promise._fulfill (D:\Portable\Code\Blog\node_modules\bluebird\js\release\promise.js:638:18)
    at D:\Portable\Code\Blog\node_modules\bluebird\js\release\nodeback.js:42:21
    at D:\Portable\Code\Blog\node_modules\graceful-fs\graceful-fs.js:78:16
    at tryToString (fs.js:513:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:501:12)
sunningoo commented 7 years ago

你没有在你的主目录的配置文件_config.yml中添加如下代码:

prism_plugin: mode: 'preprocess' # realtime/preprocess theme: 'default' line_number: false # default false

OhYee commented 7 years ago

@sunningoo 添加后是上面的提示 不添加是最后的报错 两种都没法正常运行

sunningoo commented 7 years ago

你截图一下你第一幅图的报错的第49行那附近代码,看看是不是写错了

OhYee commented 7 years ago

这个49行是哪个文件啊 blog的config是无关的内容

tim 20170808225644

sunningoo commented 7 years ago

highlight: enable: false line_number: true auto_detect: true #自动检测 tab_replace:

高亮代码

prism_plugin: mode: 'preprocess' # realtime/preprocess theme: 'atom-dark' line_number: # default false

我当时是down完主题后,直接在主目录文件下配置_config.yml文件就OK了,所以你看看你是不是哪里配置错了,根据报错信息查找一下问题

OhYee commented 7 years ago

我再找找吧,谢谢啦~ @sunningoo

Gerogina6 commented 6 years ago

@OhYee 你的问题解决了吗。。

OhYee commented 6 years ago

@Georginaaaa 没有,后来我直接前端用的highlight.js

Gerogina6 commented 6 years ago

@OhYee 那要怎么设置主题啊?

OhYee commented 6 years ago

@Georginaaaa 我后来换了自己写的博客系统了😂 如果实在不行你就换个主题吧,具体报错为啥我也不太清楚

Gerogina6 commented 6 years ago

@OhYee maybe我用回hexo原生的highlight.js